From eb6cdb603b003d3372e2892743e7bb95a2a0651e Mon Sep 17 00:00:00 2001 From: JohannesSetiawan Date: Thu, 22 Feb 2024 19:25:36 +0700 Subject: [PATCH] [RED] Add test for empty input. --- authentication/tests.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/authentication/tests.py b/authentication/tests.py index b29f48c..4958039 100644 --- a/authentication/tests.py +++ b/authentication/tests.py @@ -19,7 +19,7 @@ def testRegisterValid(self): def testEmailFormatNotValid(self): data ={ - "username":"user1", + "username":"user1", "password":"pass1", "email":"emailnotvalid" } @@ -27,4 +27,15 @@ def testEmailFormatNotValid(self): self.assertEqual(response.status_code, 400) resp_msg = json.loads(response.content.decode('utf-8'))['msg'] self.assertEqual(resp_msg,"Email format is wrong.") - self.assertFalse(AppUser.objects.filter(username='user1').exists()) \ No newline at end of file + self.assertFalse(AppUser.objects.filter(username='user1').exists()) + + def testEmptyInput(self): + data = { + "username":"", + "password":"", + "email":"" + } + response = self.client.post(reverse('authentication:register'), json.dumps(data), content_type='application/json') + self.assertEqual(response.status_code, 400) + resp_msg = json.loads(response.content.decode('utf-8'))['msg'] + self.assertEqual(resp_msg,"Empty input! Make sure all the fields are filled.") \ No newline at end of file