enabled per-company products filtering
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user