gault-millau/apps/account/tests/tests_common.py
Виктор Гладких 23759974d9 Add account/user/ test for GET
2019-09-23 15:34:40 +03:00

26 lines
788 B
Python

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)