예제 #1
0
 def test_tags(self, app):
     app.shops = [Shop(id=i, lat=i, lng=10) for i in range(20)]
     app.products = [Product(shop_id=i) for i in range(20)]
     app.tags = {'test': [1, 2]}
     filtered = filter_products(tags=[], count=10)
     assert len(filtered) == 10
     filtered = filter_products(tags=['test'], count=10)
     assert len(filtered) == 2
     assert app.products[1] in filtered
     assert app.products[2] in filtered
예제 #2
0
 def test_tags(self, app):
     app.shops = [Shop(id=i, lat=i, lng=10) for i in range(20)]
     app.products = [Product(shop_id=i) for i in range(20)]
     app.tags = {
         'test': [1, 2]
     }
     filtered = filter_products(tags=[], count=10)
     assert len(filtered) == 10
     filtered = filter_products(tags=['test'], count=10)
     assert len(filtered) == 2
     assert app.products[1] in filtered
     assert app.products[2] in filtered
예제 #3
0
 def test_tags_and_distance_intersection(self, app):
     app.shops = [Shop(id=i, lat=i, lng=10) for i in range(20)]
     app.products = [Product(shop_id=i) for i in range(20)]
     app.tags = {'test': [10, 1, 20]}
     filtered = filter_products(lat=10, lng=10, radius=1e+6, tags=['test'])
     assert len(filtered) == 1
     assert app.products[10] in filtered
예제 #4
0
 def test_tags_and_distance_intersection(self, app):
     app.shops = [Shop(id=i, lat=i, lng=10) for i in range(20)]
     app.products = [Product(shop_id=i) for i in range(20)]
     app.tags = {'test': [10, 1, 20]}
     filtered = filter_products(lat=10, lng=10, radius=1e+6, tags=['test'])
     assert len(filtered) == 1
     assert app.products[10] in filtered
예제 #5
0
 def test_distance(self, app):
     app.shops = [Shop(id=i, lat=i, lng=10) for i in range(20)]
     app.products = [Product(shop_id=i) for i in range(20)]
     filtered = filter_products(lat=10, lng=10, radius=1000)
     assert len(filtered) == 1
     assert app.products[10] in filtered
예제 #6
0
 def test_count(self, app):
     app.products = [i for i in range(50)]
     filtered = filter_products(count=35)
     assert len(filtered) == 35
예제 #7
0
 def test_distance(self, app):
     app.shops = [Shop(id=i, lat=i, lng=10) for i in range(20)]
     app.products = [Product(shop_id=i) for i in range(20)]
     filtered = filter_products(lat=10, lng=10, radius=1000)
     assert len(filtered) == 1
     assert app.products[10] in filtered
예제 #8
0
 def test_count(self, app):
     app.products = [i for i in range(50)]
     filtered = filter_products(count=35)
     assert len(filtered) == 35