Exemplo n.º 1
0
 def test_validate_invalid_password(self, user):
     """Invalid password."""
     user.set_password('example')
     user.save()
     form = LoginForm(username=user.username, password='******')
     assert form.validate() is False
     assert 'Invalid password' in form.password.errors
Exemplo n.º 2
0
 def test_validate_success(self, user):
     """Login successful."""
     user.set_password('example')
     user.save()
     form = LoginForm(username=user.username, password='******')
     assert form.validate() is True
     assert form.user == user
Exemplo n.º 3
0
 def test_validate_unknown_username(self, db):
     """
     Unknown username.
     """
     form = LoginForm(username="******", password="******")
     assert form.validate() is False
     assert "Unknown username" in form.username.errors
     assert form.user is None
Exemplo n.º 4
0
 def test_validate_inactive_user(self, user):
     """Inactive user."""
     user.active = False
     user.set_password('example')
     user.save()
     # Correct username and password, but user is not activated
     form = LoginForm(username=user.username, password='******')
     assert form.validate() is False
     assert 'User not activated' in form.username.errors
Exemplo n.º 5
0
 def test_validate_unknown_username(self, db):
     """Unknown username."""
     form = LoginForm(username='******', password='******')
     assert form.validate() is False
     assert 'Unknown username' in form.username.errors
     assert form.user is None