Skip to content

Commit

Permalink
[Chore #137592403] Adds test login redirects active user
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Kipyegon committed Feb 9, 2017
1 parent fda1d45 commit ed04bad
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
16 changes: 16 additions & 0 deletions hc/accounts/tests/test_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from django.core import mail
from django.test import TestCase
from hc.api.models import Check
from hc.accounts.models import Profile


class LoginTestCase(TestCase):
Expand Down Expand Up @@ -65,6 +66,21 @@ def test_login_with_invalid_credentials(self):
r = self.client.post("/accounts/login/", form)
self.assertTemplateUsed(r, 'accounts/login.html')

def test_login_redirects_active_user(self):
self.ken = User(username="ken", email="ken@example.org")
self.ken.set_password("password")
self.ken.is_active = True
self.ken.save()
self.ken_profile = Profile(user=self.ken, api_key="abc", token='')
self.ken_profile.team_access_allowed = True
self.ken_profile.save()
form = {'username': 'ken@example.org', 'password': "password"}
r = self.client.post("/accounts/login/", form)
self.assertEqual(r.status_code, 200)







Expand Down
1 change: 0 additions & 1 deletion hc/accounts/tests/test_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from hc.api.models import Check
from django.contrib.auth.models import User
from hc.accounts.models import Profile
from django.contrib.auth.hashers import make_password
from django.core.signing import Signer


Expand Down

0 comments on commit ed04bad

Please sign in to comment.