first try at implementing product viewset "related" action

This commit is contained in:
Sam
2021-03-08 13:47:47 +00:00
parent ff92c97d93
commit 7a1aa496b7
3 changed files with 42 additions and 12 deletions

View File

@@ -194,6 +194,21 @@ class ProductViewSetTest(APITestCase):
# Assert number of instnaces in response
self.assertEquals(len(expected_instance), len(payload))
def test_anon_can_get_related_products(self):
# Create instances
instance = self.factory()
# make our user the creator
instance.creator = self.user
instance.save()
url = f"{self.endpoint}{instance.id}/related/"
response = self.client.get(url)
self.assertEquals(response.status_code, 200)
payload= response.json()
self.assertTrue(len(payload) <= 6)
# authenticated user
def test_auth_user_can_paginate_instances(self):
"""authenticated user can paginate instances