<s> import io <EOL> import json <EOL> from tests . testing import resource_filename <EOL> from yelp . obj . business import Business <EOL> from yelp . obj . deal import Deal <EOL> from yelp . obj . location import Location <EOL> from yelp . obj . response_object import ResponseObject <EOL> class TestResponseObject ( object ) : <EOL> @ classmethod <EOL> def setup_class ( cls ) : <EOL> with io . open ( resource_filename ( '<STR_LIT>' ) ) as resp : <EOL> cls . response = json . load ( resp ) <EOL> def test_response_obj_sets_correct_fields ( self ) : <EOL> with io . open ( resource_filename ( '<STR_LIT>' ) ) as resp : <EOL> response = json . load ( resp ) <EOL> obj = ResponseObject ( '<STR_LIT:{}>' ) <EOL> obj . _fields = [ '<STR_LIT:id>' , '<STR_LIT:name>' ] <EOL> obj . __init__ ( response ) <EOL> assert obj . id == response [ '<STR_LIT:id>' ] <EOL> assert obj . name == response [ '<STR_LIT:name>' ] <EOL> assert hasattr ( obj , '<STR_LIT>' ) is False <EOL> def test_response_obj_parse_list ( self ) : <EOL> obj = ResponseObject ( '<STR_LIT:{}>' ) <EOL> obj . _parse ( '<STR_LIT>' , Deal , self . response ) <EOL> assert len ( obj . deals ) == len ( self . response [ '<STR_LIT>' ] ) <EOL> assert type ( obj . deals [ <NUM_LIT:0> ] ) is Deal <EOL> def test_response_obj_parse_one ( self ) : <EOL> obj = ResponseObject ( '<STR_LIT:{}>' ) <EOL> obj . _parse ( '<STR_LIT:location>' , Location , self . response ) <EOL> assert type ( obj . location ) is Location <EOL> def test_parse_main_response_body ( self ) : <EOL> obj = ResponseObject ( '<STR_LIT:{}>' ) <EOL> obj . _parse_main_response_body ( '<STR_LIT>' , Business , self . response ) <EOL> assert type ( obj . business ) is Business </s>
