from rest_framework.test import APITestCase from rest_framework import status from authorization.tests.tests import get_tokens_for_user from http.cookies import SimpleCookie # Create your tests here. class AccountTests(APITestCase): url = '/api/web/account/user/' def setUp(self): self.data = get_tokens_for_user() def test_user_url(self): response = self.client.get(self.url) self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED) self.client.cookies = SimpleCookie( {'access_token': self.data['tokens'].get('access_token'), 'refresh_token': self.data['tokens'].get('access_token')}) response = self.client.get(self.url) self.assertEqual(response.status_code, status.HTTP_200_OK)