Skip to content

Commit

Permalink
[RED] Add test for empty input.
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesSetiawan committed Feb 22, 2024
1 parent 73accb2 commit eb6cdb6
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions authentication/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,23 @@ def testRegisterValid(self):

def testEmailFormatNotValid(self):
data ={
"username":"user1",
"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())
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.")

0 comments on commit eb6cdb6

Please sign in to comment.