From 215b389418cf8685b40d0d96a6ed2853b0e8ab22 Mon Sep 17 00:00:00 2001 From: JohannesSetiawan Date: Thu, 22 Feb 2024 18:53:23 +0700 Subject: [PATCH] [RED] Adding new test for email format not valid. --- authentication/tests.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/authentication/tests.py b/authentication/tests.py index b1d2bb8..b29f48c 100644 --- a/authentication/tests.py +++ b/authentication/tests.py @@ -15,4 +15,16 @@ def testRegisterValid(self): } response = self.client.post(reverse('authentication:register'), json.dumps(data), content_type='application/json') self.assertEqual(response.status_code, 200) - self.assertTrue(AppUser.objects.filter(username='user1').exists()) \ No newline at end of file + self.assertTrue(AppUser.objects.filter(username='user1').exists()) + + def testEmailFormatNotValid(self): + data ={ + "username":"user1", + "password":"pass1", + "email":"emailnotvalid" + } + 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,"Email format is wrong.") + self.assertFalse(AppUser.objects.filter(username='user1').exists()) \ No newline at end of file