Skip to content

Commit

Permalink
[RED] Adding new test for email format not valid.
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesSetiawan committed Feb 22, 2024
1 parent 0d473d8 commit 215b389
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion authentication/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
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())

0 comments on commit 215b389

Please sign in to comment.