fixes to the my_ views, and their tests

This commit is contained in:
Sam
2021-02-12 12:03:16 +00:00
parent 0a61cea599
commit c4faa89a99
7 changed files with 32 additions and 7 deletions

View File

@@ -259,14 +259,23 @@ class MyCompanyViewTest(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