def test_get_business_id_with_no_result_should_raise_exception(self): responses.add(responses.GET, '{}/matches'.format(url), status=200, json={"businesses": []}) with self.assertRaises(BusinessNotFoundException): get_business_id(Place(id=1))
def test_get_rating_should_return_rating(self): business_id = 'EDjIDq3VGlDQAxtdOslPCA' responses.add(responses.GET, '{}/matches'.format(url), status=200, json={ "businesses": [{ "id": business_id, "alias": "cracker-barrel-old-country-store-hattiesburg", "name": "Cracker Barrel Old Country Store", }] }) responses.add(responses.GET, '{}/{}/reviews'.format(url, business_id), status=200, json={ "reviews": [{ "id": "mLmKOhUW87byM7lsMDDz_w", "rating": 3, }, { "id": "Al1G6S7IZcIVFdSAA-fKgw", "rating": 1, }, { "id": "3uxMqhNcZdmbt4p08gSZyQ", "rating": 2, }], "total": 46 }) self.assertEqual(2, get_rating(Place()))
def test_get_business_id_with_api_error_status_should_raise_exception( self): responses.add(responses.GET, '{}/matches'.format(url), status=400, json={}) with self.assertRaises(BusinessNotFoundException): get_business_id(Place(id=1))
def test_get_business_id_should_return_business_id(self): responses.add(responses.GET, '{}/matches'.format(url), status=200, json={ "businesses": [{ "id": "EDjIDq3VGlDQAxtdOslPCA", "alias": "cracker-barrel-old-country-store-hattiesburg", "name": "Cracker Barrel Old Country Store", }] }) self.assertEqual('EDjIDq3VGlDQAxtdOslPCA', get_business_id(Place()))