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
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
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
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
def test_count(self, app): app.products = [i for i in range(50)] filtered = filter_products(count=35) assert len(filtered) == 35