Esempio n. 1
0
def get_spot_by_id(spot_id):
    spot_client = Spotseeker()
    try:
        res = spot_client.get_spot_by_id(spot_id)
    except DataFailureException:
        return None
    return process_extended_info(res)
Esempio n. 2
0
 def test_add_payment(self):
     sc = Spotseeker()
     spot = sc.get_spot_by_id(1)
     spot = add_payment_names(spot)
     self.assertEqual(
         spot.payment_names,
         ["Cash", "Husky Card", "Mastercard", "Dining Account", "Visa"])
Esempio n. 3
0
    def test_spot_open(self):
        local_tz = pytz.timezone('America/Los_Angeles')
        sc = Spotseeker()
        spot = sc.get_spot_by_id(4)
        spot = organize_hours(spot)

        # monday
        current_time = local_tz.localize(
            datetime.datetime(2015, 12, 14, 7, 0, 0, 0))
        self.assertFalse(get_is_spot_open(spot, current_time))
        current_time = local_tz.localize(
            datetime.datetime(2015, 12, 14, 10, 30, 0, 0))
        self.assertTrue(get_is_spot_open(spot, current_time))
        # tuesday (still open from monday)
        current_time = local_tz.localize(
            datetime.datetime(2015, 12, 15, 1, 0, 0, 0))
        self.assertTrue(get_is_spot_open(spot, current_time))
        # tuesday after monday's opening is closed
        current_time = local_tz.localize(
            datetime.datetime(2015, 12, 15, 3, 0, 0, 0))
        self.assertFalse(get_is_spot_open(spot, current_time))
        # saturday (only open from friday's opening)
        current_time = local_tz.localize(
            datetime.datetime(2015, 12, 19, 10, 0, 0, 0))
        self.assertFalse(get_is_spot_open(spot, current_time))
Esempio n. 4
0
 def test_add_payment(self):
     sc = Spotseeker()
     spot = sc.get_spot_by_id(1)
     spot = add_payment_names(spot)
     self.assertEqual(spot.payment_names, ["Cash", "Husky Card",
                                           "Mastercard", "Dining Account",
                                           "Visa"])
Esempio n. 5
0
def get_spot_by_id(spot_id):
    spot_client = Spotseeker()
    try:
        res = spot_client.get_spot_by_id(spot_id)
    except DataFailureException:
        return None
    return process_extended_info(res)
Esempio n. 6
0
    def test_spot_open(self):
        local_tz = pytz.timezone('America/Los_Angeles')
        sc = Spotseeker()
        spot = sc.get_spot_by_id(4)
        spot = organize_hours(spot)

        # monday
        current_time = local_tz.localize(datetime.datetime(
            2015, 12, 14, 7, 0, 0, 0))
        self.assertFalse(get_is_spot_open(spot, current_time))
        current_time = local_tz.localize(datetime.datetime(
            2015, 12, 14, 10, 30, 0, 0))
        self.assertTrue(get_is_spot_open(spot, current_time))
        # tuesday (still open from monday)
        current_time = local_tz.localize(datetime.datetime(
            2015, 12, 15, 1, 0, 0, 0))
        self.assertTrue(get_is_spot_open(spot, current_time))
        # tuesday after monday's opening is closed
        current_time = local_tz.localize(datetime.datetime(
            2015, 12, 15, 3, 0, 0, 0))
        self.assertFalse(get_is_spot_open(spot, current_time))
        # saturday (only open from friday's opening)
        current_time = local_tz.localize(datetime.datetime(
            2015, 12, 19, 10, 0, 0, 0))
        self.assertFalse(get_is_spot_open(spot, current_time))
Esempio n. 7
0
    def test_search_spots(self):
        """ Tests search_spots function with mock data provided in the
            file named : spot?limit=5&center_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)
Esempio n. 8
0
 def test_get_avg_latlng(self):
     spots = []
     sc = Spotseeker()
     spots.append(sc.get_spot_by_id(1))
     spots.append(sc.get_spot_by_id(4))
     spots.append(sc.get_spot_by_id(5))
     avg_latlng = get_avg_latlng_for_spots(spots)
     self.assertEqual(avg_latlng, (47.65607183333333, -122.3100596))
Esempio n. 9
0
 def test_get_avg_latlng(self):
     spots = []
     sc = Spotseeker()
     spots.append(sc.get_spot_by_id(1))
     spots.append(sc.get_spot_by_id(4))
     spots.append(sc.get_spot_by_id(5))
     avg_latlng = get_avg_latlng_for_spots(spots)
     self.assertEqual(avg_latlng, (47.65607183333333, -122.3100596))
Esempio n. 10
0
def get_building_list(campus, app_type=None):
    spot_client = Spotseeker()
    buildings = []
    try:
        buildings = spot_client.get_building_list(campus, app_type)
    except DataFailureException:
        pass
        # Log the error?
    return buildings
Esempio n. 11
0
def get_building_list(campus, app_type=None):
    spot_client = Spotseeker()
    buildings = []
    try:
        buildings = spot_client.get_building_list(campus, app_type)
    except DataFailureException:
        pass
        # Log the error?
    return buildings
Esempio n. 12
0
    def test_search_spots(self):
        """ Tests search_spots function with mock data provided in the
            file named : spot?limit=5&center_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)
Esempio n. 13
0
 def test_get_building_latlng(self):
     spots = []
     sc = Spotseeker()
     spots.append(sc.get_spot_by_id(1))
     spots.append(sc.get_spot_by_id(4))
     spots.append(sc.get_spot_by_id(5))
     grouped_spots = group_spots_by_building(spots)
     grouped_spots = add_latlng_to_building(grouped_spots)
     self.assertEqual(grouped_spots[1]['latitude'], 47.656462)
     self.assertEqual(grouped_spots[1]['longitude'], -122.3125347)
Esempio n. 14
0
 def test_get_building_latlng(self):
     spots = []
     sc = Spotseeker()
     spots.append(sc.get_spot_by_id(1))
     spots.append(sc.get_spot_by_id(4))
     spots.append(sc.get_spot_by_id(5))
     grouped_spots = group_spots_by_building(spots)
     grouped_spots = add_latlng_to_building(grouped_spots)
     self.assertEqual(grouped_spots[1]['latitude'], 47.656462)
     self.assertEqual(grouped_spots[1]['longitude'], -122.3125347)
Esempio n. 15
0
 def test_spot_items(self):
     spot_client = Spotseeker()
     spot_data = spot_client.get_spot_by_id('1')
     self.assertEqual(len(spot_data.items), 2)
     item1 = spot_data.items[0]
     self.assertEqual(item1.item_id, 796)
     self.assertEqual(item1.name, "C-19074")
     self.assertEqual(item1.category, "Digital Camera")
     self.assertEqual(item1.subcategory, "")
     self.assertEqual(len(item1.images), 1),
     self.assertEqual(item1.images[0].image_id, 1),
Esempio n. 16
0
 def test_spot_items(self):
     spot_client = Spotseeker()
     spot_data = spot_client.get_spot_by_id('1')
     self.assertEqual(len(spot_data.items), 2)
     item1 = spot_data.items[0]
     self.assertEqual(item1.item_id, 796)
     self.assertEqual(item1.name, "C-19074")
     self.assertEqual(item1.category, "Digital Camera")
     self.assertEqual(item1.subcategory, "")
     self.assertEqual(len(item1.images), 1),
     self.assertEqual(item1.images[0].image_id, 1),
Esempio n. 17
0
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
Esempio n. 18
0
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
Esempio n. 19
0
    def test_group_by_building(self):
        spots = []
        sc = Spotseeker()
        spots.append(sc.get_spot_by_id(1))
        spots.append(sc.get_spot_by_id(4))
        spots.append(sc.get_spot_by_id(5))

        grouped_spots = group_spots_by_building(spots)

        self.assertEqual(len(grouped_spots), 2)
        self.assertEqual(grouped_spots[1]['name'],
                         "Odegaard Undergraduate Library")
        self.assertEqual(len(grouped_spots[1]['spots']), 2)
Esempio n. 20
0
    def test_group_by_building(self):
        spots = []
        sc = Spotseeker()
        spots.append(sc.get_spot_by_id(1))
        spots.append(sc.get_spot_by_id(4))
        spots.append(sc.get_spot_by_id(5))

        grouped_spots = group_spots_by_building(spots)

        self.assertEqual(len(grouped_spots), 2)
        self.assertEqual(grouped_spots[1]['name'],
                         "Odegaard Undergraduate Library")
        self.assertEqual(len(grouped_spots[1]['spots']), 2)
Esempio n. 21
0
    def test_open_periods(self):
        sc = Spotseeker()
        spot = sc.get_spot_by_id(1)
        spot = organize_hours(spot)

        self.assertOpenPeriods(
            spot,
            (2015, 12, 21, 0, 0, 0),
            ('morning', 'afternoon', 'evening'))

        self.assertOpenPeriods(
            spot,
            (2015, 12, 20, 0, 0, 0),
            ())

        self.assertOpenPeriods(
            spot,
            (2015, 12, 24, 0, 0, 0),
            ('morning', 'afternoon'))

        self.assertOpenPeriods(
            spot,
            (2015, 12, 25, 0, 0, 0),
            ('morning', 'afternoon', 'evening', 'late_night'))

        # Test spot open across midnight
        spot = sc.get_spot_by_id(4)
        spot = organize_hours(spot)
        self.assertOpenPeriods(
            spot,
            (2015, 12, 25, 0, 0, 0),
            ('afternoon', 'evening', 'late_night'))

        # Test spots that exactly fill period hours
        spot = sc.get_spot_by_id(5)
        spot = organize_hours(spot)
        # Monday
        self.assertOpenPeriods(spot, (2016, 4, 18, 0, 0, 0), ('late_night',))
        # Tuesday
        self.assertOpenPeriods(spot, (2016, 4, 19, 0, 0, 0), ('morning',))
        # Wednesday
        self.assertOpenPeriods(spot, (2016, 4, 20, 0, 0, 0), ('afternoon',))
        # Thursday
        self.assertOpenPeriods(spot, (2016, 4, 21, 0, 0, 0), ('evening',))
        # Friday
        self.assertOpenPeriods(spot, (2016, 4, 22, 0, 0, 0), ('late_night',))
        # Sunday
        self.assertOpenPeriods(spot, (2016, 4, 24, 0, 0, 0), ())
Esempio n. 22
0
    def test_get_spot(self):
        spot_client = Spotseeker()

        spot_data = spot_client.get_spot_by_id('123')

        self.assertEqual(spot_data.spot_id, "123")
        self.assertEqual(spot_data.name, "Test Spot")
        self.assertEqual(spot_data.uri, "/api/v1/spot/123")
        self.assertEqual(spot_data.latitude, 3.60)
        self.assertEqual(spot_data.longitude, 1.34)
        self.assertEqual(spot_data.height_from_sea_level, 0.10)
        self.assertEqual(spot_data.building_name, "Test Building")
        self.assertEqual(spot_data.floor, 0)
        self.assertEqual(spot_data.room_number, "456")
        self.assertEqual(spot_data.capacity, 0)
        self.assertEqual(spot_data.display_access_restrictions, "none")
        self.assertEqual(spot_data.organization, "Test Org")
        self.assertEqual(spot_data.manager, "Mr Test Org")
        self.assertEqual(spot_data.etag, "686897696a7c876b7e")
        self.assertEqual(spot_data.external_id, "asd123")
        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), 7)
Esempio n. 23
0
    def test_get_spot(self):
        spot_client = Spotseeker()

        spot_data = spot_client.get_spot_by_id('123')

        self.assertEqual(spot_data.spot_id, "123")
        self.assertEqual(spot_data.name, "Test Spot")
        self.assertEqual(spot_data.uri, "/api/v1/spot/123")
        self.assertEqual(spot_data.latitude, 3.60)
        self.assertEqual(spot_data.longitude, 1.34)
        self.assertEqual(spot_data.height_from_sea_level, 0.10)
        self.assertEqual(spot_data.building_name, "Test Building")
        self.assertEqual(spot_data.floor, 0)
        self.assertEqual(spot_data.room_number, "456")
        self.assertEqual(spot_data.capacity, 0)
        self.assertEqual(spot_data.display_access_restrictions, "none")
        self.assertEqual(spot_data.organization, "Test Org")
        self.assertEqual(spot_data.manager, "Mr Test Org")
        self.assertEqual(spot_data.etag, "686897696a7c876b7e")
        self.assertEqual(spot_data.external_id, "asd123")
        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), 7)
Esempio n. 24
0
 def test_add_additional_info(self):
     sc = Spotseeker()
     spot = sc.get_spot_by_id(1)
     spot = add_additional_info(spot)
     self.assertEqual(spot.has_alert, None)
     self.assertEqual(spot.alert_notes, None)
     self.assertEqual(spot.has_reservation, None)
     self.assertEqual(spot.reservation_notes, None)
     self.assertEqual(
         spot.menu_url,
         "https://www.hfs.washington.edu/uploadedFiles/Dining/"
         "Dining_Locations/Bahnwebmenu%202014.pdf")
     self.assertEqual(spot.hours_notes, None)
     self.assertEqual(spot.access_notes, None)
     self.assertEqual(spot.has_coupon, None)
     self.assertEqual(spot.coupon_expiration, None)
     self.assertEqual(spot.coupon_url, None)
     self.assertEqual(spot.phone, "206-685-4950")
     self.assertEqual(
         spot.website_url, "https://www.hfs.washington.edu/dining/"
         "Default.aspx?id=3620#gsc.tab=0")
Esempio n. 25
0
 def test_add_additional_info(self):
     sc = Spotseeker()
     spot = sc.get_spot_by_id(1)
     spot = add_additional_info(spot)
     self.assertEqual(spot.has_alert, None)
     self.assertEqual(spot.alert_notes, None)
     self.assertEqual(spot.s_has_reservation, None)
     self.assertEqual(spot.s_reservation_notes, None)
     self.assertEqual(
         spot.menu_url,
         "https://www.hfs.washington.edu/uploadedFiles/Dining/"
         "Dining_Locations/Bahnwebmenu%202014.pdf")
     self.assertEqual(spot.hours_notes, None)
     self.assertEqual(spot.access_notes, None)
     self.assertEqual(spot.has_coupon, None)
     self.assertEqual(spot.coupon_expiration, None)
     self.assertEqual(spot.coupon_url, None)
     self.assertEqual(spot.phone, "206-685-4950")
     self.assertEqual(
         spot.website_url, "https://www.hfs.washington.edu/dining/"
         "Default.aspx?id=3620#gsc.tab=0")
Esempio n. 26
0
    def test_open_periods(self):
        sc = Spotseeker()
        spot = sc.get_spot_by_id(1)
        spot = organize_hours(spot)

        self.assertOpenPeriods(spot, (2015, 12, 21, 0, 0, 0),
                               ('morning', 'afternoon', 'evening'))

        self.assertOpenPeriods(spot, (2015, 12, 20, 0, 0, 0), ())

        self.assertOpenPeriods(spot, (2015, 12, 24, 0, 0, 0),
                               ('morning', 'afternoon'))

        self.assertOpenPeriods(
            spot, (2015, 12, 25, 0, 0, 0),
            ('morning', 'afternoon', 'evening', 'late_night'))

        # Test spot open across midnight
        spot = sc.get_spot_by_id(4)
        spot = organize_hours(spot)
        self.assertOpenPeriods(spot, (2015, 12, 25, 0, 0, 0),
                               ('afternoon', 'evening', 'late_night'))

        # Test spots that exactly fill period hours
        spot = sc.get_spot_by_id(5)
        spot = organize_hours(spot)
        # Monday
        self.assertOpenPeriods(spot, (2016, 4, 18, 0, 0, 0), ('late_night', ))
        # Tuesday
        self.assertOpenPeriods(spot, (2016, 4, 19, 0, 0, 0), ('morning', ))
        # Wednesday
        self.assertOpenPeriods(spot, (2016, 4, 20, 0, 0, 0), ('afternoon', ))
        # Thursday
        self.assertOpenPeriods(spot, (2016, 4, 21, 0, 0, 0), ('evening', ))
        # Friday
        self.assertOpenPeriods(spot, (2016, 4, 22, 0, 0, 0), ('late_night', ))
        # Sunday
        self.assertOpenPeriods(spot, (2016, 4, 24, 0, 0, 0), ())
Esempio n. 27
0
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
Esempio n. 28
0
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
Esempio n. 29
0
 def test_get_all_spots(self):
     spot_client = Spotseeker()
     spots = spot_client.all_spots()
     self.assertEqual(len(spots), 3)
Esempio n. 30
0
 def test_get_all_spots(self):
     spot_client = Spotseeker()
     spots = spot_client.all_spots()
     self.assertEqual(len(spots), 3)
Esempio n. 31
0
 def test_building_list(self):
     spot_client = Spotseeker()
     buildings = spot_client.get_building_list("seattle")
     self.assertEqual(len(buildings), 43)
Esempio n. 32
0
 def test_add_foodtypes(self):
     sc = Spotseeker()
     spot = sc.get_spot_by_id(1)
     spot = add_foodtype_names_to_spot(spot)
     self.assertEqual(spot.foodtype_names, ["Entrees", "Sandwiches"])
Esempio n. 33
0
 def test_add_cuisine(self):
     sc = Spotseeker()
     spot = sc.get_spot_by_id(1)
     spot = add_cuisine_names(spot)
     self.assertEqual(spot.cuisinetype_names, ["Indian", "Vietnamese"])
Esempio n. 34
0
 def test_building_list(self):
     spot_client = Spotseeker()
     buildings = spot_client.get_building_list("seattle")
     self.assertEqual(len(buildings), 43)
Esempio n. 35
0
    def test_organize_hours_premade(self):
        sc = Spotseeker()
        spot = sc.get_spot_by_id(4)
        spot_hours = organize_hours(spot)

        self.assertEqual(len(spot_hours.hours), 7)
Esempio n. 36
0
 def test_add_foodtypes(self):
     sc = Spotseeker()
     spot = sc.get_spot_by_id(1)
     spot = add_foodtype_names_to_spot(spot)
     self.assertEqual(spot.foodtype_names, ["Entrees", "Sandwiches"])
Esempio n. 37
0
    def test_organize_hours_premade(self):
        sc = Spotseeker()
        spot = sc.get_spot_by_id(4)
        spot_hours = organize_hours(spot)

        self.assertEqual(len(spot_hours.hours), 7)
Esempio n. 38
0
 def test_add_cuisine(self):
     sc = Spotseeker()
     spot = sc.get_spot_by_id(1)
     spot = add_cuisine_names(spot)
     self.assertEqual(spot.cuisinetype_names, ["Indian", "Vietnamese"])
Esempio n. 39
0
 def test_bad_spot(self):
     spot_client = Spotseeker()
     self.assertRaises(DataFailureException, spot_client.get_spot_by_id,
                       999)
Esempio n. 40
0
def get_item_image(item_id, image_id, width=None):
    ss = Spotseeker()
    return ss.get_item_image(item_id, image_id, width)