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_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_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