def setup_class(cls): with io.open(resource_filename('json/credentials.json')) as cred: test_creds = json.load(cred) auth = Oauth1Authenticator(**test_creds) cls.client = Client(auth) with io.open(resource_filename('json/search_response.json')) as resp: cls.search_response = json.load(resp) with io.open(resource_filename('json/business_response.json')) as resp: cls.business_response = json.load(resp)
def test_init_user(): with io.open(resource_filename('json/business_response.json')) as biz: response = json.load(biz)['reviews'][0]['user'] user = User(response) assert user.id == response['id'] assert user.image_url == response['image_url'] assert user.name == response['name']
def test_init_location_no_coordinate(): with io.open(resource_filename('json/business_response.json')) as biz: response = json.load(biz)['location'] response.pop('coordinate', None) location = Location(response) assert location.address == response['address'] assert location.coordinate is None
def test_init_review(): with io.open(resource_filename('json/business_response.json')) as biz: response = json.load(biz)['reviews'][0] review = Review(response) assert review.id == response['id'] assert type(review.rating) is Rating assert type(review.user) is User
def test_init_phone_search_response(): with io.open(resource_filename('json/search_response.json')) as ps: response = json.load(ps) obj = SearchResponse(response) assert len(obj.businesses) == len(response['businesses']) assert type(obj.region) == Region assert type(obj.region.center) == Coordinate
def test_business_category_is_tuple(): with io.open(resource_filename('json/business_response.json')) as biz: response = json.load(biz) business = Business(response) assert type(business.categories[0]) is Category assert business.categories[0].name == "Indian" assert business.categories[0].alias == "indpak"
def setup_class(cls): with io.open( resource_filename('json/credentials_secret.json'), ) as cred: test_creds = json.load(cred) auth = Oauth1Authenticator(**test_creds) cls.client = Client(auth)
def test_response_obj_sets_correct_fields(self): with io.open(resource_filename('json/test_response.json')) as resp: response = json.load(resp) obj = ResponseObject('{}') obj._fields = ['id', 'name'] obj.__init__(response) assert obj.id == response['id'] assert obj.name == response['name'] assert hasattr(obj, 'do_not_display') is False
def test_error_handler_raises_correct_yelp_error(self): with io.open( resource_filename('json/error_response.json'), 'rb', ) as resp_file: response = resp_file.read().replace(b'\n', b'') error = mock.Mock() error.code = 400 error.msg = 'Bad Request' error.read.return_value = response with pytest.raises(InvalidParameter) as err: self.handler.raise_error(error) assert "radius_filter" in err.value.text
class IntegrationTest(object): int_vcr = vcr.VCR( cassette_library_dir=resource_filename('integration/vcr_cassettes'), match_on=['method'], path_transformer=vcr.VCR.ensure_suffix('.yaml')) cassette_params = { 'filter_query_parameters': [ 'oauth_consumer_key', 'oauth_token', 'oauth_body_hash', 'oauth_nonce', 'oauth_signature' ] } @classmethod def setup_class(cls): with io.open( resource_filename('json/credentials_secret.json'), ) as cred: test_creds = json.load(cred) auth = Oauth1Authenticator(**test_creds) cls.client = Client(auth)
def test_init_review(): with io.open(resource_filename('json/business_response.json')) as biz: response = json.load(biz)['reviews'][0] review = Review(response) assert review.id == response['id'] assert type(review.user) is User
def test_init_gift_certificate_option(): with io.open(resource_filename('json/business_response.json')) as biz: response = json.load(biz)['gift_certificates'][0]['options'][0] gift_certificate_option = GiftCertificateOption(response) assert gift_certificate_option.price == response['price']
def test_init_deal_option(): with io.open(resource_filename('json/business_response.json')) as biz: response = json.load(biz)['deals'][0]['options'][0] deal_option = DealOption(response) assert deal_option.purchase_url == response['purchase_url']
def test_init_rating(): with io.open(resource_filename('json/business_response.json')) as biz: response = json.load(biz)['reviews'][0] rating = Rating(response) assert rating.rating == response['rating'] assert rating.img_url == response['rating_image_url']
def setup_class(cls): with io.open(resource_filename('json/credentials.json')) as cred: test_creds = json.load(cred) cls.auth = Oauth1Authenticator(**test_creds)
def test_init_business(): with io.open(resource_filename('json/business_response.json')) as biz: response = json.load(biz) business = Business(response) assert business.id == response['id']
def test_init_gift_certificate(): with io.open(resource_filename('json/business_response.json')) as biz: response = json.load(biz)['gift_certificates'][0] gift_certificate = GiftCertificate(response) assert gift_certificate.id == response['id']
def setup_class(cls): with io.open(resource_filename('json/business_response.json')) as resp: cls.response = json.load(resp)
def test_init_location(): with io.open(resource_filename('json/business_response.json')) as biz: response = json.load(biz)['location'] location = Location(response) assert location.address == response['address'] assert type(location.coordinate) is Coordinate
def test_init_deal(): with io.open(resource_filename('json/business_response.json')) as biz: response = json.load(biz)['deals'][0] deal = Deal(response) assert deal.url == response['url']