def test_paging_query_3(self): args = MultiDict([('page', '1')]) query = getSortAndPageQuery(Restaurant.query, args, Restaurant) response = query.all() self.assertTrue(len(response) <= 12) for place in response: self.assertTrue(isinstance(place, Restaurant))
def test_rating_filter_query_3(self): args = MultiDict([('rating', '4')]) query = getFilterQuery(Attraction.query, args, Attraction) response = query.all() for place in response: self.assertTrue(isinstance(place, Attraction)) self.assertTrue(place.rating >= 4)
def test_paging_query_1(self): args = MultiDict([('page', '1')]) query = getSortAndPageQuery(Attraction.query, args, Attraction) response = query.all() self.assertTrue(len(response) <= 12) for place in response: self.assertTrue(isinstance(place, Attraction))
def test_zipcode_filter_query_2(self): args = MultiDict([('zipcode', '78701')]) query = getFilterQuery(Hotel.query, args, Hotel) response = query.all() for place in response: self.assertTrue(isinstance(place, Hotel)) self.assertEqual(place.zipcode, 78701)
def test_rating_filter_query_2(self): args = MultiDict([('rating', '4')]) query = getFilterQuery(Restaurant.query, args, Restaurant) response = query.all() for place in response: self.assertTrue(isinstance(place, Restaurant)) self.assertTrue(place.rating >= 4)
def test_search_query_5(self): args = MultiDict([('search', 'Austin')]) query = getSearchQuery(args, Attraction) response = query.all() for place in response: self.assertTrue(isinstance(place, Attraction)) self.assertTrue("austin" in place.name.lower() or "austin" in str(place.zipcode))
def test_search_query_1(self): args = MultiDict([('search', 'taco')]) query = getSearchQuery(args, Restaurant) response = query.all() for place in response: self.assertTrue(isinstance(place, Restaurant)) self.assertTrue("taco" in place.name.lower() or "taco" in str(place.zipcode))
def test_sorting_query_6(self): args = MultiDict([('order_by', 'name'), ('order', 'desc')]) query = getSortAndPageQuery(Restaurant.query, args, Restaurant) response = query.all() pre_name = response[0].name for place in response: self.assertTrue(isinstance(place, Restaurant)) self.assertTrue(pre_name >= place.name) pre_name = place.name
def test_sorting_query_5(self): args = MultiDict([('order_by', 'rating'), ('order', 'asc')]) query = getSortAndPageQuery(Restaurant.query, args, Restaurant) response = query.all() pre_rating = response[0].rating for place in response: self.assertTrue(isinstance(place, Restaurant)) self.assertTrue(pre_rating <= place.rating) pre_rating = place.rating
def test_categories_filter_query_6(self): args = MultiDict([('categories', 'hiking,parks')]) query = getFilterQuery(Attraction.query, args, Attraction) response = query.all() for place in response: self.assertTrue(isinstance(place, Attraction)) haveCategories = False for assoc in place.categories: haveCategories = haveCategories or assoc.category_id == "hiking" or assoc.category_id == "parks" self.assertTrue(haveCategories)
def test_categories_filter_query_4(self): args = MultiDict([('categories', 'musicvenues,divebars')]) query = getFilterQuery(Hotel.query, args, Hotel) response = query.all() for place in response: self.assertTrue(isinstance(place, Hotel)) haveCategories = False for assoc in place.categories: haveCategories = haveCategories or assoc.category_id == "musicvenues" or assoc.category_id == "divebars" self.assertTrue(haveCategories)
def test_categories_filter_query_2(self): args = MultiDict([('categories', 'japanese,cocktailbars')]) query = getFilterQuery(Restaurant.query, args, Restaurant) response = query.all() for place in response: self.assertTrue(isinstance(place, Restaurant)) haveCategories = False for assoc in place.categories: haveCategories = haveCategories or assoc.category_id == "japanese" or assoc.category_id == "cocktailbars" self.assertTrue(haveCategories)
def test_search_query_6(self): args = MultiDict([('search', 'austin,78701'), ('search_type', 'and')]) query = getSearchQuery(args, Attraction) response = query.all() for place in response: self.assertTrue(isinstance(place, Attraction)) name_check = "austin" in place.name.lower( ) or "78701" in place.name.lower() zipcode_check = "austin" in str(place.zipcode) or "78701" in str( place.zipcode) self.assertTrue(name_check and zipcode_check)
def test_search_query_2(self): args = MultiDict([('search', 'taco,78701'), ('search_type', 'and')]) query = getSearchQuery(args, Restaurant) response = query.all() for place in response: self.assertTrue(isinstance(place, Restaurant)) name_check = "taco" in place.name.lower( ) or "78701" in place.name.lower() zipcode_check = "taco" in str(place.zipcode) or "78701" in str( place.zipcode) self.assertTrue(name_check and zipcode_check)