fixes to the my_ views, and their tests
This commit is contained in:
@@ -500,14 +500,23 @@ class MyProductsViewTest(APITestCase):
|
||||
self.user.save()
|
||||
|
||||
def test_auth_user_gets_data(self):
|
||||
# create instance
|
||||
user_instances = [
|
||||
self.factory(creator=self.user),
|
||||
self.factory(creator=self.user),
|
||||
]
|
||||
|
||||
# Authenticate
|
||||
token = get_tokens_for_user(self.user)
|
||||
self.client.credentials(HTTP_AUTHORIZATION=f"Bearer {token['access']}")
|
||||
|
||||
# Query endpoint
|
||||
response = self.client.get(self.endpoint)
|
||||
payload = response.json()
|
||||
|
||||
# Assert forbidden code
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
self.assertEquals(len(user_instances), len(payload))
|
||||
|
||||
def test_anon_user_cannot_access(self):
|
||||
# send in request
|
||||
|
||||
Reference in New Issue
Block a user