forked from DGNum/gestioCOF
Fix tests
This commit is contained in:
parent
a34b83c236
commit
6a11139588
7 changed files with 28 additions and 13 deletions
|
@ -356,7 +356,9 @@ class TestReventeManageTest(TestCase):
|
|||
|
||||
def test_can_get(self):
|
||||
client = Client()
|
||||
client.force_login(self.user)
|
||||
client.force_login(
|
||||
self.user, backend="django.contrib.auth.backends.ModelBackend"
|
||||
)
|
||||
r = client.get(self.url)
|
||||
self.assertEqual(r.status_code, 200)
|
||||
|
||||
|
|
|
@ -27,7 +27,9 @@ class TestHomeView(TestCase):
|
|||
def test_get(self, mock_messages):
|
||||
user = User.objects.create_user(username="random_user")
|
||||
give_bds_buro_permissions(user)
|
||||
self.client.force_login(user)
|
||||
self.client.force_login(
|
||||
user, backend="django.contrib.auth.backends.ModelBackend"
|
||||
)
|
||||
resp = self.client.get(reverse("bds:home"))
|
||||
self.assertEquals(resp.status_code, 200)
|
||||
|
||||
|
@ -44,7 +46,7 @@ class TestRegistrationView(TestCase):
|
|||
self.assertRedirects(resp, login_url(next=url))
|
||||
|
||||
# Logged-in but unprivileged GET
|
||||
client.force_login(user)
|
||||
client.force_login(user, backend="django.contrib.auth.backends.ModelBackend")
|
||||
resp = client.get(url)
|
||||
self.assertEquals(resp.status_code, 403)
|
||||
|
||||
|
@ -64,7 +66,7 @@ class TestRegistrationView(TestCase):
|
|||
self.assertRedirects(resp, login_url(next=url))
|
||||
|
||||
# Logged-in but unprivileged GET
|
||||
client.force_login(user)
|
||||
client.force_login(user, backend="django.contrib.auth.backends.ModelBackend")
|
||||
resp = client.get(url)
|
||||
self.assertEquals(resp.status_code, 403)
|
||||
|
||||
|
|
|
@ -54,7 +54,9 @@ class CSVExportAccessTest(MessagePatch, TestCase):
|
|||
|
||||
def test_get(self):
|
||||
client = Client()
|
||||
client.force_login(self.staff)
|
||||
client.force_login(
|
||||
self.staff, backend="django.contrib.auth.backends.ModelBackend"
|
||||
)
|
||||
r = client.get(self.url)
|
||||
self.assertEqual(r.status_code, 200)
|
||||
|
||||
|
@ -66,7 +68,7 @@ class CSVExportAccessTest(MessagePatch, TestCase):
|
|||
|
||||
def test_unauthorised(self):
|
||||
client = Client()
|
||||
client.force_login(self.u1)
|
||||
client.force_login(self.u1, backend="django.contrib.auth.backends.ModelBackend")
|
||||
r = client.get(self.url)
|
||||
self.assertEqual(r.status_code, 403)
|
||||
|
||||
|
@ -86,7 +88,9 @@ class CSVExportContentTest(MessagePatch, CSVResponseMixin, TestCase):
|
|||
)
|
||||
self.staff = make_staff_user("staff")
|
||||
self.client = Client()
|
||||
self.client.force_login(self.staff)
|
||||
self.client.force_login(
|
||||
self.staff, backend="django.contrib.auth.backends.ModelBackend"
|
||||
)
|
||||
|
||||
def test_simple_event(self):
|
||||
self.event.subscribers.set([self.u1, self.u2])
|
||||
|
|
|
@ -641,7 +641,7 @@ class ClubListViewTests(ViewTestCaseMixin, TestCase):
|
|||
def test_as_staff(self):
|
||||
u = self.users["staff"]
|
||||
c = Client()
|
||||
c.force_login(u)
|
||||
c.force_login(u, backend="django.contrib.auth.backends.ModelBackend")
|
||||
|
||||
r = c.get(self.url)
|
||||
|
||||
|
@ -686,7 +686,7 @@ class ClubMembersViewTests(ViewTestCaseMixin, TestCase):
|
|||
self.c.respos.add(u)
|
||||
|
||||
c = Client()
|
||||
c.force_login(u)
|
||||
c.force_login(u, backend="django.contrib.auth.backends.ModelBackend")
|
||||
r = c.get(self.url)
|
||||
|
||||
self.assertEqual(r.status_code, 200)
|
||||
|
|
|
@ -211,7 +211,7 @@ class OpenKfetConsumerTest(ChannelTestCase):
|
|||
)
|
||||
t.user_permissions.add(is_team)
|
||||
c = WSClient()
|
||||
c.force_login(t)
|
||||
c.force_login(t, backend="django.contrib.auth.backends.ModelBackend")
|
||||
|
||||
# connect
|
||||
c.send_and_consume(
|
||||
|
@ -251,7 +251,9 @@ class OpenKfetScenarioTest(ChannelTestCase):
|
|||
self.r_c.login(username="root", password="root")
|
||||
# its client (for websockets)
|
||||
self.r_c_ws = WSClient()
|
||||
self.r_c_ws.force_login(self.r)
|
||||
self.r_c_ws.force_login(
|
||||
self.r, backend="django.contrib.auth.backends.ModelBackend"
|
||||
)
|
||||
|
||||
self.kfet_open = OpenKfet(
|
||||
cache_prefix="test_kfetopen_%s" % random.randrange(2 ** 20)
|
||||
|
|
|
@ -253,7 +253,10 @@ class ViewTestCaseMixin(TestCaseMixin):
|
|||
self.register_user(label, user)
|
||||
|
||||
if self.auth_user:
|
||||
self.client.force_login(self.users[self.auth_user])
|
||||
self.client.force_login(
|
||||
self.users[self.auth_user],
|
||||
backend="django.contrib.auth.backends.ModelBackend",
|
||||
)
|
||||
|
||||
def tearDown(self):
|
||||
del self.users_base
|
||||
|
|
|
@ -77,7 +77,9 @@ class PetitCoursInscriptionViewTestCase(ViewTestCaseMixin, TestCase):
|
|||
self.subject2 = create_petitcours_subject(name="Matière 2")
|
||||
|
||||
def test_get_forbidden_user_not_cof(self):
|
||||
self.client.force_login(self.users["user"])
|
||||
self.client.force_login(
|
||||
self.users["user"], backend="django.contrib.auth.backends.ModelBackend"
|
||||
)
|
||||
resp = self.client.get(self.url)
|
||||
self.assertRedirects(resp, reverse("cof-denied"))
|
||||
|
||||
|
|
Loading…
Reference in a new issue