mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-11-16 09:34:03 +01:00
Tests: remove useless Client instance.
This commit is contained in:
@@ -92,14 +92,14 @@ class AccountTestCase(ModoTestCase):
|
||||
self._set_quota("user@test.com", 0)
|
||||
|
||||
def test_set_nul_quota_as_domainadmin(self):
|
||||
self.clt.logout()
|
||||
self.client.logout()
|
||||
self.assertTrue(
|
||||
self.clt.login(username="admin@test.com", password="toto")
|
||||
self.client.login(username="admin@test.com", password="toto")
|
||||
)
|
||||
self._set_quota("user@test.com", 0, 400)
|
||||
self.clt.logout()
|
||||
self.client.logout()
|
||||
self.assertTrue(
|
||||
self.clt.login(username="admin@test2.com", password="toto")
|
||||
self.client.login(username="admin@test2.com", password="toto")
|
||||
)
|
||||
self._set_quota("user@test2.com", 0)
|
||||
|
||||
@@ -142,7 +142,7 @@ class PermissionsTestCase(ModoTestCase):
|
||||
)
|
||||
|
||||
def tearDown(self):
|
||||
self.clt.logout()
|
||||
self.client.logout()
|
||||
|
||||
def test_domain_admins(self):
|
||||
self.ajax_post(
|
||||
@@ -177,9 +177,9 @@ class PermissionsTestCase(ModoTestCase):
|
||||
username="user@test.com").is_superuser, False)
|
||||
|
||||
def test_self_modif(self):
|
||||
self.clt.logout()
|
||||
self.client.logout()
|
||||
self.assertTrue(
|
||||
self.clt.login(username="admin@test.com", password="toto")
|
||||
self.client.login(username="admin@test.com", password="toto")
|
||||
)
|
||||
admin = User.objects.get(username="admin@test.com")
|
||||
values = dict(
|
||||
@@ -204,14 +204,14 @@ class PermissionsTestCase(ModoTestCase):
|
||||
self.assertEqual(admin.group, "DomainAdmins")
|
||||
|
||||
def test_domadmin_access(self):
|
||||
self.clt.logout()
|
||||
self.client.logout()
|
||||
self.assertEqual(
|
||||
self.clt.login(username="admin@test.com", password="toto"),
|
||||
self.client.login(username="admin@test.com", password="toto"),
|
||||
True)
|
||||
response = self.clt.get(reverse("admin:domain_list"))
|
||||
response = self.client.get(reverse("admin:domain_list"))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
response = self.clt.get(
|
||||
response = self.client.get(
|
||||
reverse("admin:account_change", args=[self.user.id]),
|
||||
HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
||||
self.assertNotEqual(response["Content-Type"], "application/json")
|
||||
@@ -234,8 +234,8 @@ class PermissionsTestCase(ModoTestCase):
|
||||
values
|
||||
)
|
||||
account = User.objects.get(username="superadmin2@test.com")
|
||||
self.clt.logout()
|
||||
self.clt.login(username="admin@test.com", password="toto")
|
||||
self.client.logout()
|
||||
self.client.login(username="admin@test.com", password="toto")
|
||||
self.ajax_post(
|
||||
reverse("admin:account_delete", args=[account.id]), {}, 403
|
||||
)
|
||||
|
||||
@@ -141,7 +141,7 @@ class DomainTestCase(ModoTestCase):
|
||||
|
||||
def test_domain_flat_list(self):
|
||||
"""Test the 'domain_flat_list' view."""
|
||||
response = self.clt.get(reverse("admin:domain_flat_list"))
|
||||
response = self.client.get(reverse("admin:domain_flat_list"))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
content = json.loads(response.content)
|
||||
self.assertIn("test.com", content)
|
||||
|
||||
@@ -18,11 +18,11 @@ class ExportTestCase(ModoTestCase):
|
||||
factories.populate_database()
|
||||
|
||||
def __export_identities(self, idtfilter="", grpfilter=""):
|
||||
self.clt.get(
|
||||
self.client.get(
|
||||
reverse("admin:_identity_list") +
|
||||
"?grpfilter=%s&idtfilter=%s" % (grpfilter, idtfilter)
|
||||
)
|
||||
return self.clt.post(
|
||||
return self.client.post(
|
||||
reverse("admin:identity_export"),
|
||||
{"filename": "test.csv"}
|
||||
)
|
||||
|
||||
@@ -22,7 +22,7 @@ class ImportTestCase(ModoTestCase):
|
||||
domain; domain2.com; 200; False
|
||||
domainalias; domalias1.com; domain1.com; True
|
||||
""", name="domains.csv")
|
||||
self.clt.post(
|
||||
self.client.post(
|
||||
reverse("admin:domain_import"), {
|
||||
"sourcefile": f
|
||||
}
|
||||
@@ -45,7 +45,7 @@ domainalias; domalias1.com; domain1.com; True
|
||||
f = ContentFile(b"""domain;test.alias;10;True
|
||||
domainalias;test.alias;test.com;True
|
||||
""", name="domains.csv")
|
||||
resp = self.clt.post(
|
||||
resp = self.client.post(
|
||||
reverse("admin:domain_import"), {
|
||||
"sourcefile": f
|
||||
}
|
||||
@@ -61,7 +61,7 @@ forward; alias2@test.com; True; user1+ext@test.com
|
||||
forward; fwd1@test.com; True; user@extdomain.com
|
||||
dlist; dlist@test.com; True; user1@test.com; user@extdomain.com
|
||||
""", name="identities.csv")
|
||||
self.clt.post(
|
||||
self.client.post(
|
||||
reverse("admin:identity_import"),
|
||||
{"sourcefile": f, "crypt_password": True}
|
||||
)
|
||||
@@ -79,7 +79,7 @@ dlist; dlist@test.com; True; user1@test.com; user@extdomain.com
|
||||
self.assertTrue(admin.is_owner(mb1))
|
||||
self.assertEqual(mb1.full_address, "user1@test.com")
|
||||
self.assertTrue(
|
||||
self.clt.login(username="user1@test.com", password="toto")
|
||||
self.client.login(username="user1@test.com", password="toto")
|
||||
)
|
||||
|
||||
da = User.objects.get(username="truc@test.com")
|
||||
@@ -127,7 +127,7 @@ dlist; dlist@test.com; True; user1@test.com; user@extdomain.com
|
||||
f = ContentFile(b"""
|
||||
account; user1@nonlocal.com; toto; User; One; True; SimpleUsers; user1@nonlocal.com; 0
|
||||
""", name="identities.csv")
|
||||
self.clt.post(
|
||||
self.client.post(
|
||||
reverse("admin:identity_import"),
|
||||
{"sourcefile": f, "crypt_password": True}
|
||||
)
|
||||
@@ -138,7 +138,7 @@ account; user1@nonlocal.com; toto; User; One; True; SimpleUsers; user1@nonlocal.
|
||||
f = ContentFile(b"""
|
||||
account; user1@test.com; toto; User; One; True; SimpleUsers; user1@test.com; ; test.com
|
||||
""", name="identities.csv")
|
||||
resp = self.clt.post(
|
||||
resp = self.client.post(
|
||||
reverse("admin:identity_import"),
|
||||
{"sourcefile": f, "crypt_password": True}
|
||||
)
|
||||
@@ -146,12 +146,12 @@ account; user1@test.com; toto; User; One; True; SimpleUsers; user1@test.com; ; t
|
||||
|
||||
def test_import_domain_by_domainadmin(self):
|
||||
"""Check if a domain admin is not allowed to import a domain."""
|
||||
self.clt.logout()
|
||||
self.clt.login(username="admin@test.com", password="toto")
|
||||
self.client.logout()
|
||||
self.client.login(username="admin@test.com", password="toto")
|
||||
f = ContentFile(b"""
|
||||
domain; domain2.com; 200; False
|
||||
""", name="identities.csv")
|
||||
resp = self.clt.post(
|
||||
resp = self.client.post(
|
||||
reverse("admin:identity_import"),
|
||||
{"sourcefile": f, "crypt_password": True}
|
||||
)
|
||||
@@ -159,7 +159,7 @@ domain; domain2.com; 200; False
|
||||
f = ContentFile(b"""
|
||||
domainalias; domalias1.com; test.com; True
|
||||
""", name="identities.csv")
|
||||
resp = self.clt.post(
|
||||
resp = self.client.post(
|
||||
reverse("admin:identity_import"),
|
||||
{"sourcefile": f, "crypt_password": True}
|
||||
)
|
||||
@@ -167,12 +167,12 @@ domainalias; domalias1.com; test.com; True
|
||||
"You are not allowed to import domain aliases", resp.content)
|
||||
|
||||
def test_import_quota_too_big(self):
|
||||
self.clt.logout()
|
||||
self.clt.login(username="admin@test.com", password="toto")
|
||||
self.client.logout()
|
||||
self.client.login(username="admin@test.com", password="toto")
|
||||
f = ContentFile(b"""
|
||||
account; user1@test.com; toto; User; One; True; SimpleUsers; user1@test.com; 20
|
||||
""", name="identities.csv")
|
||||
resp = self.clt.post(
|
||||
resp = self.client.post(
|
||||
reverse("admin:identity_import"),
|
||||
{"sourcefile": f, "crypt_password": True}
|
||||
)
|
||||
@@ -182,7 +182,7 @@ account; user1@test.com; toto; User; One; True; SimpleUsers; user1@test.com; 20
|
||||
f = ContentFile(b"""
|
||||
account; user1@test.com; toto; User; One; True; SimpleUsers; user1@test.com
|
||||
""", name="identities.csv")
|
||||
self.clt.post(
|
||||
self.client.post(
|
||||
reverse("admin:identity_import"),
|
||||
{"sourcefile": f, "crypt_password": True}
|
||||
)
|
||||
@@ -197,7 +197,7 @@ account; user1@test.com; toto; User; One; True; SimpleUsers; user1@test.com
|
||||
account; admin@test.com; toto; Admin; ; True; DomainAdmins; admin@test.com; 0; test.com
|
||||
account; truc@test.com; toto; René; Truc; True; DomainAdmins; truc@test.com; 0; test.com
|
||||
""", name="identities.csv")
|
||||
self.clt.post(
|
||||
self.client.post(
|
||||
reverse("admin:identity_import"),
|
||||
{"sourcefile": f, "crypt_password": True,
|
||||
"continue_if_exists": True}
|
||||
@@ -211,14 +211,14 @@ account; truc@test.com; toto; René; Truc; True; DomainAdmins; truc@test.com; 0;
|
||||
|
||||
Expected result: no
|
||||
"""
|
||||
self.clt.logout()
|
||||
self.client.logout()
|
||||
self.assertTrue(
|
||||
self.clt.login(username="admin@test.com", password="toto")
|
||||
self.client.login(username="admin@test.com", password="toto")
|
||||
)
|
||||
f = ContentFile(b"""
|
||||
account; sa@test.com; toto; Super; Admin; True; SuperAdmins; superadmin@test.com; 50
|
||||
""", name="identities.csv")
|
||||
self.clt.post(
|
||||
self.client.post(
|
||||
reverse("admin:identity_import"),
|
||||
{"sourcefile": f, "crypt_password": True,
|
||||
"continue_if_exists": True}
|
||||
@@ -230,7 +230,7 @@ account; sa@test.com; toto; Super; Admin; True; SuperAdmins; superadmin@test.com
|
||||
f = ContentFile(b"""
|
||||
alias;user.alias@test.com;True;user@test.com;;;;;;;;;;;;;;;;
|
||||
""", name="identities.csv")
|
||||
self.clt.post(
|
||||
self.client.post(
|
||||
reverse("admin:identity_import"),
|
||||
{"sourcefile": f, "crypt_password": True,
|
||||
"continue_if_exists": True}
|
||||
|
||||
@@ -14,8 +14,8 @@ class ForwardTestCase(ModoTestCase):
|
||||
populate_database()
|
||||
|
||||
def test_forward_permissions(self):
|
||||
self.clt.logout()
|
||||
self.clt.login(username='user@test.com', password='toto')
|
||||
self.client.logout()
|
||||
self.client.login(username='user@test.com', password='toto')
|
||||
self.ajax_post(
|
||||
reverse('user_forward'),
|
||||
{'dest': 'user@extdomain.com', 'keepcopies': True}
|
||||
|
||||
Reference in New Issue
Block a user