New unit test.

see #596
This commit is contained in:
Antoine Nguyen
2015-11-16 14:51:05 +01:00
parent 64ca18891e
commit 63b7fabb08
2 changed files with 24 additions and 0 deletions
+3
View File
@@ -12,6 +12,9 @@ from modoboa.lib import parameters
class LoginForm(forms.Form):
"""User login form."""
username = forms.CharField(
label=ugettext_lazy("Username"),
widget=forms.TextInput(attrs={"class": "form-control"})
+21
View File
@@ -6,6 +6,27 @@ from modoboa.lib.tests import ModoTestCase
from . import factories
class AuthenticationTestCase(ModoTestCase):
"""Validate authentication scenarios."""
@classmethod
def setUpTestData(cls):
"""Create test data."""
super(AuthenticationTestCase, cls).setUpTestData()
cls.account = factories.UserFactory(
username="user@test.com", groups=('SimpleUsers',)
)
def test_authentication(self):
"""Validate simple case."""
self.clt.logout()
data = {"username": "user@test.com", "password": "toto"}
response = self.clt.post(reverse("core:login"), data)
self.assertEqual(response.status_code, 302)
self.assertTrue(response.url.endswith(reverse("core:user_index")))
class ProfileTestCase(ModoTestCase):
@classmethod