Fakultas Ilmu Komputer UI

Commit 66348f93 authored by Kefas Satrio Bangkit Solideantyo's avatar Kefas Satrio Bangkit Solideantyo
Browse files

[RED] add tests for user name

parent 4115e465
Pipeline #71880 failed with stage
in 7 minutes and 16 seconds
......@@ -56,16 +56,16 @@ class UserModelTests(APITestCase):
problem_to_solve=2,
health_problem=[1])
cls.custom_user_1 = CustomUser.objects.create_user(email='email@email.com', password='abc')
cls.custom_user_1 = CustomUser.objects.create_user(name='tes', email='email@email.com', password='abc')
cls.custom_user_2 = CustomUser.objects.create_user(email='email2@gmail.com', password='abc')
cls.custom_user_2 = CustomUser.objects.create_user(name='tes', email='email2@gmail.com', password='abc')
cls.num_of_diet_profile = DietProfile.objects.count()
cls.num_of_custom_user = CustomUser.objects.count()
def test_create_user(self):
user = CustomUser.objects.create_user(email='email2@email.com', password='tes',
diet_profile=self.diet_profile_1,)
user = CustomUser.objects.create_user(name='tes', email='email2@email.com',
password='tes', diet_profile=self.diet_profile_1,)
self.assertEqual(str(user), 'email2@email.com')
self.assertEqual(user.email, 'email2@email.com')
self.assertTrue(user.is_active)
......@@ -105,6 +105,7 @@ class UserModelTests(APITestCase):
def test_post_registration_user_succeed(self):
data = {
'name': 'tes',
'email': 'abc123@gmail.com',
'password1': '2828abab',
'password2': '2828abab',
......@@ -128,6 +129,7 @@ class UserModelTests(APITestCase):
def test_post_registration_user_failed_because_different_password(self):
data = {
'name': 'tes',
'email': 'abc123@gmail.com',
'password1': '2828abaab',
'password2': '2828abab',
......@@ -139,6 +141,7 @@ class UserModelTests(APITestCase):
def test_post_registration_user_failed_because_email_already_registered(self):
data = {
'name': 'tes',
'email': self.custom_user_1.email,
'password1': '2828abaab',
'password2': '2828abaab',
......@@ -192,7 +195,8 @@ class UserModelTests(APITestCase):
self.assertIn('access_token', json_response)
self.assertIn('refresh_token', json_response)
self.assertIn('user', json_response)
self.assertTrue(json_response.get('user').get('id'))
self.assertEquals(json_response.get('user').get('id'), 2)
self.assertEquals(json_response.get('user').get('name'), 'tes')
self.assertEqual(response.status_code, status.HTTP_200_OK)
def test_post_login_user_failed_because_non_existing_email(self):
......
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