Skip to content

Commit

Permalink
[RED] Add test for Logout feature.
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesSetiawan committed Feb 22, 2024
1 parent 6d4f744 commit e5174fd
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 @@ -5,6 +5,7 @@

REGISTER_LINK = reverse('authentication:register')
LOGIN_LINK = reverse('authentication:login')
LOGOUT_LINK = reverse('authentication:logout')

class RegisterTest(TestCase):

Expand Down Expand Up @@ -68,4 +69,15 @@ def testLoginFailed(self):
data = {'username': 'testuser', 'password': 'testwrongpassword'}
response = self.client.post(LOGIN_LINK, json.dumps(data), content_type='application/json')
self.assertEqual(response.status_code, 400)
self.assertEqual(response.json()['msg'],"Wrong username/password!")
self.assertEqual(response.json()['msg'],"Wrong username/password!")

class LogoutTest(TestCase):
def setUp(self):
self.client = Client()
self.user = AppUser.objects.create_user(email='[email protected]',username='testuser',password='test')
self.client.login(username = 'testuser', password = 'test')

def logoutTest(self):
response = self.client.post(LOGOUT_LINK)
self.assertEqual(response.status_code, 200)

0 comments on commit e5174fd

Please sign in to comment.