unified the db queries in product search, one per chunk

This commit is contained in:
Sam
2021-02-15 11:07:22 +00:00
parent ef0f36bff5
commit c38e9dd822
2 changed files with 17 additions and 18 deletions

View File

@@ -462,7 +462,9 @@ class ProductSearchTest(TestCase):
def test_anon_user_can_search(self):
expected_instances = [
self.factory(description="zapatos verdes"),
self.factory(tags="colores/rojos"),
self.factory(tags="colores/rojos, "),
self.factory(description="zapatos rojos"),
self.factory(attributes='"lunares rojos", '),
]
unexpected_instances = [
self.factory(description="chanclas"),
@@ -476,10 +478,11 @@ class ProductSearchTest(TestCase):
url = f"{self.endpoint}?query_string={query_string}"
# send in request
response = self.client.get(url)
payload = response.json()
# check response
self.assertEqual(response.status_code, 200)
# check for object creation
self.assertEquals(len(response.data['products']), len(expected_instances))
self.assertEquals(len(payload['products']), len(expected_instances))
class MyProductsViewTest(APITestCase):