small fixes
This commit is contained in:
@@ -81,7 +81,7 @@ class ProductViewSetTest(APITestCase):
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
|
||||
# authenticated user
|
||||
def test_auth_user_can_list_instance(self):
|
||||
def test_auth_user_can_list_instances(self):
|
||||
"""Regular logged-in user can list instance
|
||||
"""
|
||||
# Create instances
|
||||
@@ -100,6 +100,25 @@ class ProductViewSetTest(APITestCase):
|
||||
# Assert all instances are returned
|
||||
self.assertEqual(len(instances), len(response.data))
|
||||
|
||||
def test_auth_user_can_get_instance(self):
|
||||
"""Regular logged-in user can list instance
|
||||
"""
|
||||
# Create instances
|
||||
instance = self.factory()
|
||||
|
||||
# Authenticate user
|
||||
token = get_tokens_for_user(self.user)
|
||||
self.client.credentials(HTTP_AUTHORIZATION=f"Bearer {token['access']}")
|
||||
|
||||
# Request list
|
||||
url = f"{self.endpoint}{instance.id}/"
|
||||
response = self.client.get(url)
|
||||
|
||||
# Assert access is allowed
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
data = json.loads(response.content)
|
||||
self.assertEquals(instance.id, data['id'])
|
||||
|
||||
def test_auth_user_can_create_instance(self):
|
||||
"""Regular logged-in user can create new instance
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user