def test_execute_business_queries(self): for kwargs in self.valid_argument_list: results = yelp.get_businesses(simplify=False, **kwargs) self.assertEqual(type(results), dict) self.assertEqual(list(results.keys()), ['businesses', 'total', 'region']) time.sleep(1.0)
def test_execute_business_queries_just_one_simplified(self): kwargs = self.valid_argument_list[0] results = yelp.get_businesses(**kwargs) self.assertEqual(type(results), list) self.assertGreaterEqual(len(results), 1) self.assertEqual(type(results[0]), dict) keys = set(results[0].keys()) if 'price' in keys: keys.remove('price') self.assertSetEqual( keys, set([ 'id', 'name', 'rating', 'image_url', 'display_address', 'coordinates', 'review_count', 'share_url', 'categories' ])) time.sleep(1.0)
def test_get_formatted_business_table(self): business = yelp.get_businesses()[0] reviews = yelp.get_reviews(business['id']) table_text = yelp.get_formatted_business_table(business, reviews, to_html=False) table_html = yelp.get_formatted_business_table(business, reviews, to_html=True) # print(table_text) # print(table_html) self.assertIn( '------------------------------------------------------------------------\nKABUL HOUSE', table_text) self.assertIn( '<h1>KABUL HOUSE</h1><table style="border-collapse: collapse; border: solid 1px #CCC;width:700px;">', table_html) time.sleep(1.0)
# pip3 install folium import folium from apis import yelp def get_file_path(file_name, subdirectory=None): import os import sys dir_path = os.path.dirname(sys.argv[0]) if subdirectory: return os.path.join(dir_path, subdirectory, file_name) else: return os.path.join(dir_path, file_name) businesses = yelp.get_businesses() # create map: map = folium.Map( location=[41.867226, -87.615355], #lat, lng zoom_start=13, tiles="Stamen watercolor") # add marker at Shedd Aquarium: marker = folium.Marker(location=[41.867226, -87.615355], popup='Shedd Aquarium') marker.add_to(map) # show map: map.save(get_file_path('my_map.html', subdirectory='results'))
from apis import yelp help(yelp) data = yelp.get_businesses() print(data) html_businesses = yelp.get_formatted_business_table(data[0], reviews=[])