mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-21 21:53:30 +00:00
Fix tests
This commit is contained in:
parent
59f5917b8c
commit
20ff409547
@ -12,6 +12,7 @@ class ClubTest(TestCase):
|
||||
call_command("populate")
|
||||
self.skia = User.objects.filter(username="skia").first()
|
||||
self.rbatsbak = User.objects.filter(username="rbatsbak").first()
|
||||
self.guy = User.objects.filter(username="guy").first()
|
||||
self.bdf = Club.objects.filter(unix_name="bdf").first()
|
||||
|
||||
def test_create_add_user_to_club_from_root_ok(self):
|
||||
@ -19,39 +20,39 @@ class ClubTest(TestCase):
|
||||
self.client.post(reverse("club:club_members", kwargs={"club_id":self.bdf.id}), {"user": self.skia.id, "role": 3})
|
||||
response = self.client.get(reverse("club:club_members", kwargs={"club_id":self.bdf.id}))
|
||||
self.assertTrue(response.status_code == 200)
|
||||
self.assertTrue("skia - Responsable info</li>" in str(response.content))
|
||||
self.assertTrue("S' Kia</a></td>\\n <td>Responsable info</td>" in str(response.content))
|
||||
|
||||
def test_create_add_user_to_club_from_root_fail_not_subscriber(self):
|
||||
self.client.login(username='root', password='plop')
|
||||
response = self.client.post(reverse("club:club_members", kwargs={"club_id":self.bdf.id}), {"user": 3, "role": 3})
|
||||
response = self.client.post(reverse("club:club_members", kwargs={"club_id":self.bdf.id}), {"user": self.guy.id, "role": 3})
|
||||
self.assertTrue(response.status_code == 200)
|
||||
self.assertTrue('<ul class="errorlist nonfield"><li>' in str(response.content))
|
||||
response = self.client.get(reverse("club:club_members", kwargs={"club_id":self.bdf.id}))
|
||||
self.assertFalse("guy - Responsable info</li>" in str(response.content))
|
||||
self.assertFalse("Guy Carlier</a></td>\\n <td>Responsable info</td>" in str(response.content))
|
||||
|
||||
def test_create_add_user_to_club_from_root_fail_already_in_club(self):
|
||||
self.client.login(username='root', password='plop')
|
||||
self.client.post(reverse("club:club_members", kwargs={"club_id":self.bdf.id}), {"user": 2, "role": 3})
|
||||
self.client.post(reverse("club:club_members", kwargs={"club_id":self.bdf.id}), {"user": self.skia.id, "role": 3})
|
||||
response = self.client.get(reverse("club:club_members", kwargs={"club_id":self.bdf.id}))
|
||||
self.assertTrue("skia - Responsable info</li>" in str(response.content))
|
||||
response = self.client.post(reverse("club:club_members", kwargs={"club_id":self.bdf.id}), {"user": 2, "role": 4})
|
||||
self.assertTrue("S' Kia</a></td>\\n <td>Responsable info</td>" in str(response.content))
|
||||
response = self.client.post(reverse("club:club_members", kwargs={"club_id":self.bdf.id}), {"user": self.skia.id, "role": 4})
|
||||
self.assertTrue(response.status_code == 200)
|
||||
self.assertFalse("skia - Secrétaire</li>" in str(response.content))
|
||||
self.assertFalse("S' Kia</a></td>\\n <td>Secrétaire</td>" in str(response.content))
|
||||
|
||||
def test_create_add_user_to_club_from_skia_ok(self):
|
||||
self.client.login(username='root', password='plop')
|
||||
self.client.post(reverse("club:club_members", kwargs={"club_id":self.bdf.id}), {"user": 2, "role": 10})
|
||||
self.client.post(reverse("club:club_members", kwargs={"club_id":self.bdf.id}), {"user": self.skia.id, "role": 10})
|
||||
self.client.login(username='skia', password='plop')
|
||||
self.client.post(reverse("club:club_members", kwargs={"club_id":self.bdf.id}), {"user": self.rbatsbak.id, "role": 9})
|
||||
response = self.client.get(reverse("club:club_members", kwargs={"club_id":self.bdf.id}))
|
||||
self.assertTrue(response.status_code == 200)
|
||||
self.assertTrue("rbatsbak - Vice-Pr" in str(response.content))
|
||||
self.assertTrue("""Richard Batsbak</a></td>\\n <td>Vice-Pr\\xc3\\xa9sident</td>""" in str(response.content))
|
||||
|
||||
def test_create_add_user_to_club_from_richard_fail(self):
|
||||
self.client.login(username='root', password='plop')
|
||||
self.client.post(reverse("club:club_members", kwargs={"club_id":self.bdf.id}), {"user": self.rbatsbak.id, "role": 3})
|
||||
self.client.login(username='rbatsbak', password='plop')
|
||||
response = self.client.post(reverse("club:club_members", kwargs={"club_id":self.bdf.id}), {"user": 4, "role": 10})
|
||||
response = self.client.post(reverse("club:club_members", kwargs={"club_id":self.bdf.id}), {"user": self.skia.id, "role": 10})
|
||||
self.assertTrue(response.status_code == 200)
|
||||
self.assertTrue("<li>You do not have the permission to do that</li>" in str(response.content))
|
||||
|
||||
|
@ -146,6 +146,7 @@ class ClubMembersView(ClubTabsMixin, CanViewMixin, UpdateView):
|
||||
request.user.is_root):
|
||||
return self.form_valid(form)
|
||||
else:
|
||||
form.add_error(None, _("You do not have the permission to do that"))
|
||||
return self.form_invalid(form)
|
||||
else:
|
||||
return self.form_invalid(form)
|
||||
|
@ -161,7 +161,7 @@ class UserRegistrationTest(TestCase):
|
||||
})
|
||||
response = c.post(reverse('core:login'), {'username': 'gcarlier', 'password': 'guy'})
|
||||
self.assertTrue(response.status_code == 200)
|
||||
self.assertTrue('<ul class="errorlist nonfield">' in str(response.content))
|
||||
self.assertTrue("""<p>Votre nom d\\'utilisateur et votre mot de passe ne correspondent pas. Merci de r\\xc3\\xa9essayer.</p>""" in str(response.content))
|
||||
|
||||
class PageHandlingTest(TestCase):
|
||||
def setUp(self):
|
||||
|
Loading…
Reference in New Issue
Block a user