def integration_test_yelp_place_details(): client_api_key = os.environ['RYR_COLLECTOR_YELP_API_KEY'] client = CollectorClient('yelp', api_key=client_api_key) client.authenticate() place_details = client.place_details('krzzyozIVGC7pX1lfVO40w') print(json.dumps(place_details))
def integration_test_yelp_search_place(): client_api_key = os.environ['RYR_COLLECTOR_YELP_API_KEY'] client = CollectorClient('yelp', api_key=client_api_key) client.authenticate() search_result = client.search_places( '221 West North Loop Boulevard, Austin', terms='Epoch Coffee', limit=1) print(json.dumps(search_result))
def collect_place_details_from_google(place_id): """Collect business information from Google.""" # Prepare client. client = CollectorClient( 'google', api_key=os.environ['RYR_COLLECTOR_GOOGLE_PLACES_API_KEY']) client.authenticate() # Retrieve detailed results. details = client.get_place_details(place_id) return details
def collect_place_details_from_yelp(name, address): """Collect business information from Yelp.""" # Prepare client. client = CollectorClient('yelp', api_key=os.environ['RYR_COLLECTOR_YELP_API_KEY']) client.authenticate() # Retrieve detailed results. client.search_places(address, terms=name, limit=1) place_summary = client.retrieve_search_summary(0) if not place_summary: raise ValueError('Yelp did not return any result.') # Extract the place_id. details = client.get_place_details(place_summary.place_id) return details
def integration_test_yelp_retrieve_place_details(): client_api_key = os.environ['RYR_COLLECTOR_YELP_API_KEY'] client = CollectorClient('yelp', api_key=client_api_key) client.authenticate() epoch_search_summary = PlaceSearchSummary( 'krzzyozIVGC7pX1lfVO40w', 'Epoch Coffee', '221 West North Loop Boulevard, Austin', ) place_details = client.retrieve_place_details( epoch_search_summary.place_id, epoch_search_summary.name, epoch_search_summary.address, ) print(json.dumps(place_details))
def integration_test_full_google_yelp_workflow(): """""" places_api_key = os.environ['RYR_COLLECTOR_GOOGLE_PLACES_API_KEY'] yelp_api_key = os.environ['RYR_COLLECTOR_YELP_API_KEY'] epoch_latlong = (30.3186037, -97.72454019999999) gmaps_places = GoogleCollector() gmaps_places.authenticate(api_key=places_api_key) s = gmaps_places.search_places(epoch_latlong) epoch_search_summary = gmaps_places.retrieve_search_summary(1) yelp = CollectorClient('yelp', api_key=yelp_api_key) yelp.authenticate() place_details = yelp.retrieve_place_details( epoch_search_summary.place_id, epoch_search_summary.name, epoch_search_summary.address, ) print(json.dumps(place_details))
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))
def test_authenticate_02(self): """Ensure the generic client can authenticate to google.""" c = CollectorClient('google', api_key=self.fake.pystr()) with pytest.raises(ValueError): c.authenticate() assert True
def test_authenticate_01(self): """Ensure the generic client can authenticate to yelp.""" c = CollectorClient('yelp', api_key=self.fake.pystr()) c.authenticate() assert True
def test_authenticate_00(self): """Ensure an invalid provider raises an error.""" c = CollectorClient(self.fake.pystr()) with pytest.raises(ValueError): c.authenticate() assert True