From 9a33bf25e0882ae57d2643086b850e5179eb2d64 Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Fri, 9 Sep 2016 11:53:31 +0200 Subject: [PATCH] Increase coverage. see #891 --- modoboa/core/tests.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/modoboa/core/tests.py b/modoboa/core/tests.py index 442d97ae8..133f6821c 100644 --- a/modoboa/core/tests.py +++ b/modoboa/core/tests.py @@ -44,6 +44,37 @@ class AuthenticationTestCase(ModoTestCase): self.assertTrue(response.url.endswith(reverse("core:dashboard"))) +class DashboardTestCase(ModoTestCase): + """Dashboard tests.""" + + @classmethod + def setUpTestData(cls): + """Create some data.""" + super(DashboardTestCase, cls).setUpTestData() + cls.dadmin = factories.UserFactory( + username="admin@test.com", groups=("DomainAdmins",) + ) + cls.user = factories.UserFactory( + username="user@test.com", groups=("SimpleUsers",) + ) + + def test_access(self): + """Load dashboard.""" + url = reverse("core:dashboard") + response = self.client.get(url) + self.assertEqual(response.status_code, 200) + self.assertIn("Latest news", response.content) + self.client.logout() + self.client.login(username=self.dadmin.username, password="toto") + response = self.client.get(url) + self.assertEqual(response.status_code, 200) + self.assertIn("Latest news", response.content) + self.client.logout() + self.client.login(username=self.user.username, password="toto") + response = self.client.get(url) + self.assertEqual(response.status_code, 302) + + class LDAPTestCaseMixin(object): """Set of methods used to test LDAP features."""