enabled per-company products filtering

This commit is contained in:
Sam
2021-02-23 13:40:49 +00:00
parent e945bd72a3
commit 4f39963691
2 changed files with 22 additions and 7 deletions

View File

@@ -83,8 +83,8 @@ class ProductViewSetTest(APITestCase):
def test_anon_user_can_filter_name(self):
# create instances
self.factory(name='product1', tags="zapatos, verdes")
self.factory(name='product2', tags="rojos")
expected = self.factory(name='product1', tags="zapatos, verdes")
unexpected = self.factory(name='product2', tags="rojos")
url = f"{self.endpoint}?name=product1"
@@ -96,12 +96,14 @@ class ProductViewSetTest(APITestCase):
self.assertEqual(response.status_code, status.HTTP_200_OK)
# Assert number of instnaces in response
self.assertEquals(1, len(payload))
self.assertEquals(payload[0]['tags'], expected.tags)
def test_anon_user_can_filter_tags(self):
# create instances
expected_instance = [
self.factory(name='product1', tags="zapatos, rojos"),
self.factory(name='product2', tags="rojos")
self.factory(name='product2', tags="rojos"),
self.factory(name='product2', tags="colores, rojos")
]
unexpected_instance = [
self.factory(name='sadfdsa', tags="zapatos, azules"),
@@ -123,7 +125,8 @@ class ProductViewSetTest(APITestCase):
# create instances
expected_instance = [
self.factory(attributes='xxl', tags="zapatos, rojos"),
self.factory(attributes='blue, xxl', tags="rojos")
self.factory(attributes='blue, xxl', tags="rojos"),
self.factory(attributes='sizes xxl', tags="rojos")
]
unexpected_instance = [
self.factory(name='sadfdsa', tags="zapatos, azules"),
@@ -145,7 +148,8 @@ class ProductViewSetTest(APITestCase):
# create instances
expected_instance = [
self.factory(category='ropa', tags="zapatos, rojos"),
self.factory(category='ropa', tags="rojos")
self.factory(category='ropa', tags="rojos"),
self.factory(category='ropa', tags="colores/rojos"),
]
unexpected_instance = [
self.factory(category='roperos', tags="zapatos, azules"),
@@ -181,7 +185,6 @@ class ProductViewSetTest(APITestCase):
# Request list
response = self.client.get(url)
payload = response.json()
import ipdb; ipdb.set_trace()
# Assert access is granted
self.assertEqual(response.status_code, status.HTTP_200_OK)