Fakultas Ilmu Komputer UI

Commit a52585d9 authored by Usman Sidiq's avatar Usman Sidiq
Browse files

[RED] Add test for email verification and adding uncovered tests

parent 8fd17973
Pipeline #45256 failed with stages
in 2 minutes and 31 seconds
......@@ -57,6 +57,37 @@ class UserTests(APITestCase):
json_test = json.loads(response.content)
self.assertEqual(len(json_test), 1)
def test_incomplete_create_user(self):
url = reverse('create-user')
data = {'name': 'Astray',
'email':'astrayyahoo@gmail.com',
'password':'chingchenghanji',
'is_active': True}
response = self.client.post(url, data)
self.assertEqual(response.status_code, status.HTTP_500_INTERNAL_SERVER_ERROR)
json_response = json.loads(response.content)
self.assertEqual(json_response['response'], 'bad request. \'phone_number\' key needed')
def test_user_already_exist(self):
url = reverse('create-user')
data = {'name': 'Astraykai',
'email':'astraykai@gmail.com',
'phone_number':'089892218567',
'password':'chingchenghanji',
'is_active': True}
response = self.client.post(url, data)
self.assertEqual(response.status_code, status.HTTP_500_INTERNAL_SERVER_ERROR)
json_response = json.loads(response.content)
self.assertEqual(json_response['response'], 'User is already exist')
def test_invalid_request(self):
url = reverse('create-user')
response = self.client.get(url)
self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)
json_response = json.loads(response.content)
print(json_response)
self.assertEqual(json_response['response'], 'get post request instead')
def test_account_login(self):
pass
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment