def test_lookup_place_00(self, mocker): """Ensure lookup fails when invoked without arguments.""" c = CollectorClient(self.fake.pystr()) with pytest.raises(ValueError): c.lookup_place() assert True
def test_lookup_place_01(self, mocker): """Ensure lookup returns details for a given place_id.""" fake_place_id = self.fake.pystr() c = CollectorClient(self.fake.pystr()) c.get_place_details = mocker.Mock() c.lookup_place(place_id=fake_place_id) c.get_place_details.assert_called_with(fake_place_id)
def test_lookup_place_02(self, mocker): """Ensure lookup returns details for a given name/address pair.""" fake_place_id = self.fake.pystr() fake_name = self.fake.pystr() fake_address = self.fake.address() c = CollectorClient(self.fake.pystr()) c.search_places = mocker.Mock() c.retrieve_search_summary = mocker.Mock( return_value=PlaceSearchSummary(place_id=fake_place_id)) c.get_place_details = mocker.Mock() c.lookup_place(name=fake_name, address=fake_address) c.search_places.assert_called_with(address=fake_address, terms=fake_name, limit=1) c.get_place_details.assert_called_with(fake_place_id)
def integration_test_full_google_yelp_workflow_with_generic(): """""" places_api_key = os.environ['RYR_COLLECTOR_GOOGLE_PLACES_API_KEY'] yelp_api_key = os.environ['RYR_COLLECTOR_YELP_API_KEY'] # Simulate a click Epoch Coffee Shop - Northloop on the map. epoch_latlong = (30.3186037, -97.72454019999999) epoch_latlong = (30.319136, -97.724303) # Retrieve the places nearby the location clicked on the map. gmap = GoogleCollector() gmap.authenticate(api_key=places_api_key) places_nearby = gmap.search_places_nearby(epoch_latlong) # Act like a user chose Epoch Coffee Shop - Northloop in the result list. epoch_search_summary = gmap.retrieve_search_summary(1) print(epoch_search_summary) # Lookup the place on Google Maps. google = CollectorClient('google', api_key=places_api_key) google.authenticate() google_place_details = google.lookup_place(epoch_search_summary.place_id) gb = google.to_business_info() print('*** Google:') print(gb) # Lookup the place on Yelp. yelp = CollectorClient('yelp', api_key=yelp_api_key, weight=10) yelp.authenticate() yelp_place_details = yelp.lookup_place(None, epoch_search_summary.name, epoch_search_summary.address) yb = yelp.to_business_info() print('*** Yelp:') print(yb) # Merge the results. print('*** Merged:') print(gb.merge(yb))