improvement to custom user endpoint
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import random
|
||||
import string
|
||||
import json
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
@@ -36,11 +37,21 @@ class CustomUserViewSetTest(APITestCase):
|
||||
"""Not logged-in user can create new instance of User but it's inactive
|
||||
TODO: should create inactive user
|
||||
"""
|
||||
data = {
|
||||
'email': 'test@email.com',
|
||||
'full_name': 'TEST NAME',
|
||||
'password1': 'VENTILADORES1234499.89',
|
||||
'password2': 'VENTILADORES1234499.89',
|
||||
}
|
||||
|
||||
# Query endpoint
|
||||
response = self.client.post(self.endpoint, data={})
|
||||
# Assert access is forbidden
|
||||
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)
|
||||
response = self.client.post(self.endpoint, data=data)
|
||||
|
||||
# Assert creation is successful
|
||||
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
|
||||
# assert instance is inactive
|
||||
info = json.loads(response.content)
|
||||
self.assertFalse(info['is_active'])
|
||||
|
||||
def test_anon_user_cannot_modify_existing_instance(self):
|
||||
"""Not logged-in user cannot modify existing instance
|
||||
|
||||
Reference in New Issue
Block a user