def test_search_spots(self): """ Tests search_spots function with mock data provided in the file named : spot?limit=5¢er_latitude=47.653811& center_longitude=-122.307815&distance=100000& fuzzy_hours_start=Tuesday%2C05%3A00&fuzzy_hours_end= Tuesday%2C11%3A00&extended_info%3Aapp_type=food tests mock data is accessible if filename matches order of query_tuple passed. """ spot_client = Spotseeker() query_tuple = [ ('limit', 5), ('center_latitude', u'47.653811'), ('center_longitude', u'-122.307815'), ('distance', 100000), ('fuzzy_hours_start', 'Tuesday,05:00'), ('fuzzy_hours_end', 'Tuesday,11:00'), ('extended_info:app_type', 'food')] spot_data_list = spot_client.search_spots(query_tuple) spot_data = spot_data_list[0] self.assertEqual(len(spot_data_list), 5) self.assertEqual(spot_data.spot_id, 40) self.assertEqual(spot_data.name, "TestSpot1") self.assertEqual(spot_data.uri, "/api/v1/spot/40") self.assertEqual(spot_data.latitude, 47) self.assertEqual(spot_data.longitude, -12) self.assertEqual(spot_data.height_from_sea_level, 0.10) self.assertEqual(spot_data.building_name, "TestBuilding") self.assertEqual(spot_data.capacity, 0) self.assertEqual(spot_data.organization, "Test Org") self.assertEqual(spot_data.manager, "Test Manager") self.assertEqual(spot_data.etag, "123456789") self.assertEqual(spot_data.last_modified, parse_datetime("2012-07-13T05:00:00+00:00")) self.assertEqual(len(spot_data.images), 1) self.assertEqual(spot_data.images[0].image_id, "1") self.assertEqual(spot_data.images[0].url, "/api/v1/spot/123/image/1") self.assertEqual(spot_data.images[0].content_type, "image/jpeg") self.assertEqual(spot_data.images[0].width, 0) self.assertEqual(spot_data.images[0].height, 0) self.assertEqual(spot_data.images[0].creation_date, parse_datetime("Sun, 06 Nov 1994 08:49:37 GMT")) self.assertEqual(spot_data.images[0].modification_date, parse_datetime("Mon, 07 Nov 1994 01:49:37 GMT")) self.assertEqual(spot_data.images[0].upload_user, "user name") self.assertEqual(spot_data.images[0].upload_application, "application name") self.assertEqual(spot_data.images[0].thumbnail_root, "/api/v1/spot/123/image/1/thumb") self.assertEqual(spot_data.images[0].description, "Information about the image") self.assertEqual(spot_data.images[0].display_index, 0) self.assertEqual(len(spot_data.spot_availability), 5)
def test_search_spots(self): """ Tests search_spots function with mock data provided in the file named : spot?limit=5¢er_latitude=47.653811& center_longitude=-122.307815&distance=100000& fuzzy_hours_start=Tuesday%2C05%3A00&fuzzy_hours_end= Tuesday%2C11%3A00&extended_info%3Aapp_type=food tests mock data is accessible if filename matches order of query_tuple passed. """ spot_client = Spotseeker() query_tuple = [('limit', 5), ('center_latitude', u'47.653811'), ('center_longitude', u'-122.307815'), ('distance', 100000), ('fuzzy_hours_start', 'Tuesday,05:00'), ('fuzzy_hours_end', 'Tuesday,11:00'), ('extended_info:app_type', 'food')] spot_data_list = spot_client.search_spots(query_tuple) spot_data = spot_data_list[0] self.assertEqual(len(spot_data_list), 5) self.assertEqual(spot_data.spot_id, 40) self.assertEqual(spot_data.name, "TestSpot1") self.assertEqual(spot_data.uri, "/api/v1/spot/40") self.assertEqual(spot_data.latitude, 47) self.assertEqual(spot_data.longitude, -12) self.assertEqual(spot_data.height_from_sea_level, 0.10) self.assertEqual(spot_data.building_name, "TestBuilding") self.assertEqual(spot_data.capacity, 0) self.assertEqual(spot_data.organization, "Test Org") self.assertEqual(spot_data.manager, "Test Manager") self.assertEqual(spot_data.etag, "123456789") self.assertEqual(spot_data.last_modified, parse_datetime("2012-07-13T05:00:00+00:00")) self.assertEqual(len(spot_data.images), 1) self.assertEqual(spot_data.images[0].image_id, "1") self.assertEqual(spot_data.images[0].url, "/api/v1/spot/123/image/1") self.assertEqual(spot_data.images[0].content_type, "image/jpeg") self.assertEqual(spot_data.images[0].width, 0) self.assertEqual(spot_data.images[0].height, 0) self.assertEqual(spot_data.images[0].creation_date, parse_datetime("Sun, 06 Nov 1994 08:49:37 GMT")) self.assertEqual(spot_data.images[0].modification_date, parse_datetime("Mon, 07 Nov 1994 01:49:37 GMT")) self.assertEqual(spot_data.images[0].upload_user, "user name") self.assertEqual(spot_data.images[0].upload_application, "application name") self.assertEqual(spot_data.images[0].thumbnail_root, "/api/v1/spot/123/image/1/thumb") self.assertEqual(spot_data.images[0].description, "Information about the image") self.assertEqual(spot_data.images[0].display_index, 0) self.assertEqual(len(spot_data.spot_availability), 5)
def get_spots_by_filter(filters=[]): spot_client = Spotseeker() res = [] try: spots = spot_client.search_spots(filters) for spot in spots: spot = process_extended_info(spot) if spot is not None: res.append(spot) except DataFailureException: # TODO: consider logging on failure pass return res
def get_spots_by_filter(filters=[]): spot_client = Spotseeker() res = [] try: spots = spot_client.search_spots(filters) for spot in spots: spot = process_extended_info(spot) if spot is not None: res.append(spot) except DataFailureException: # TODO: consider logging on failure pass return res
def get_spot_list(app_type=None, groups=[]): spot_client = Spotseeker() res = [] filters = [] filters.append(('limit', 0)) try: if app_type: filters.append(('extended_info:app_type', app_type)) else: # study spots have no app_type, and must filter on something filters.append(('open_now', 'true')) for group in groups: filters.append(('extended_info:group', group)) spots = spot_client.search_spots(filters) for spot in spots: spot = process_extended_info(spot) if spot is not None: res.append(spot) except DataFailureException: # TODO: consider logging on failure pass return res
def get_spot_list(app_type=None, groups=[]): spot_client = Spotseeker() res = [] filters = [] filters.append(('limit', 0)) try: if app_type: filters.append(('extended_info:app_type', app_type)) else: # study spots have no app_type, and must filter on something filters.append(('open_now', 'true')) for group in groups: filters.append(('extended_info:group', group)) spots = spot_client.search_spots(filters) for spot in spots: spot = process_extended_info(spot) if spot is not None: res.append(spot) except DataFailureException: # TODO: consider logging on failure pass return res