user modification enabled

This commit is contained in:
Sam
2021-02-01 13:32:34 +00:00
parent b8cd663fee
commit ee33b327fa
5 changed files with 45 additions and 8 deletions

View File

@@ -43,6 +43,7 @@ class CustomUserViewSetTest(APITestCase):
'email': 'test@email.com',
'full_name': 'TEST NAME',
'password': 'VENTILADORES1234499.89',
'provider': 'TWITTER',
}
# Query endpoint
@@ -57,7 +58,6 @@ class CustomUserViewSetTest(APITestCase):
self.assertNotEqual('', new_user.password)
# assert instance is inactive
info = json.loads(response.content)
self.assertFalse(info['is_active'])
def test_anon_user_cannot_modify_existing_instance(self):
@@ -110,6 +110,27 @@ class CustomUserViewSetTest(APITestCase):
# Assert access is forbidden
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
def test_regular_user_can_modify_own_instance(self):
"""Regular user can modify own instance
"""
# Create instance
data = {
"email": "new_email@mail.com",
"full_name": "New Full Name",
"password": "SUPERSECRETNEWPASSWORD",
}
# Authenticate
token = get_tokens_for_user(self.user)
self.client.credentials(HTTP_AUTHORIZATION=f"Bearer {token['access']}")
# Query endpoint
url = self.endpoint + f'{self.user.pk}/'
response = self.client.put(url, data=data, format='json')
# Assert forbidden code
self.assertEqual(response.status_code, status.HTTP_200_OK)
def test_regular_user_cannot_modify_existing_instance(self):
"""Regular user cannot modify existing instance
"""