Fakultas Ilmu Komputer UI

Commit 21d8da7b authored by Ami's avatar Ami
Browse files

adding id on customuser's string representation + changing tests to follow suit

parent d1d1d3ab
Pipeline #80636 passed with stages
in 13 minutes
......@@ -7,7 +7,7 @@ class UserAdmin(BaseUserAdmin):
# The fields to be used in displaying the User model.
# These override the definitions on the base UserAdmin
# that reference specific fields on auth.User.
list_display = ('email',)
list_display = ('email','id')
fieldsets = (
(None, {'fields': (\
'name',
......
......@@ -35,4 +35,4 @@ class CustomUser(AbstractBaseUser, PermissionsMixin):
objects = CustomUserManager()
def __str__(self):
return str(self.email)
return f"{self.email} + {self.id}"
......@@ -105,7 +105,7 @@ class UserModelTests(APITestCase):
def test_create_user(self):
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(str(user), 'email2@email.com + ' + str(user.id))
self.assertEqual(user.email, 'email2@email.com')
self.assertTrue(user.groups.filter(name='client').exists())
self.assertTrue(user.is_active)
......
......@@ -235,7 +235,7 @@ class WeeklyReportTest(APITestCase):
self.assertEqual(response.status_code, status.HTTP_200_OK)
def test_weekly_report_string(self):
self.assertEqual(str(self.weekly_report_1), 'email2@email.com - Test, S.Gz - Week 1')
self.assertEqual(str(self.weekly_report_1), f'email2@email.com + {self.custom_user_2.id} - Test, S.Gz - Week 1')
class WeeklyReportCommentTest(APITestCase):
......
......@@ -64,7 +64,7 @@ class DietQuestionnaireTests(APITestCase):
def test_string_representation(self):
self.assertEqual(str(self.diet_questionnaire), 'email@email.com')
self.assertEqual(str(self.diet_questionnaire), f'email@email.com + {self.custom_user_1.id}')
def test_get_all_diet_questionnaire(self):
self.client.credentials(HTTP_AUTHORIZATION=self.login_credentials)
......
......@@ -306,7 +306,7 @@ class DietRecommendationTests(APITestCase):
cls.login_credentials = "Bearer " + cls.json_login_response['access_token']
def test_string_representation(self):
self.assertEqual(str(self.diet_recommendation), 'email2@email.com - Test, S.Gz')
self.assertEqual(str(self.diet_recommendation), f'email2@email.com + {self.custom_user_2.id} - Test, S.Gz')
def test_create_diet_recommendation_succeed(self):
tmp_file = SimpleUploadedFile("testfile.pdf", bytes("abc", 'utf-8'), content_type="application/pdf")
......
Markdown is supported
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