mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 06:03:20 +00:00
Fix tests
This commit is contained in:
parent
7002139176
commit
db712c86b8
@ -2,49 +2,56 @@ from django.test import TestCase
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.core.management import call_command
|
||||
|
||||
from core.models import User
|
||||
from club.models import Club
|
||||
|
||||
# Create your tests here.
|
||||
|
||||
class ClubTest(TestCase):
|
||||
def setUp(self):
|
||||
call_command("populate")
|
||||
self.skia = User.objects.filter(username="skia").first()
|
||||
self.rbatsbak = User.objects.filter(username="rbatsbak").first()
|
||||
self.bdf = Club.objects.filter(unix_name="bdf").first()
|
||||
|
||||
def test_create_add_user_to_club_from_root_ok(self):
|
||||
self.client.login(username='root', password='plop')
|
||||
self.client.post(reverse("club:club_members", kwargs={"club_id":4}), {"user": 2, "role": 3})
|
||||
response = self.client.get(reverse("club:club_members", kwargs={"club_id":4}))
|
||||
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("<li>Woenzel'UT - skia - Responsable info</li>" in str(response.content))
|
||||
self.assertTrue("skia - Responsable info</li>" 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":4}), {"user": 3, "role": 3})
|
||||
response = self.client.post(reverse("club:club_members", kwargs={"club_id":self.bdf.id}), {"user": 3, "role": 3})
|
||||
self.assertTrue(response.status_code == 200)
|
||||
self.assertTrue("User must be subscriber to take part to a club" in str(response.content))
|
||||
response = self.client.get(reverse("club:club_members", kwargs={"club_id":4}))
|
||||
self.assertFalse("<li>Woenzel'UT - guy - Responsable info</li>" in str(response.content))
|
||||
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))
|
||||
|
||||
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":4}), {"user": 2, "role": 3})
|
||||
response = self.client.get(reverse("club:club_members", kwargs={"club_id":4}))
|
||||
self.assertTrue("<li>Woenzel'UT - skia - Responsable info</li>" in str(response.content))
|
||||
response = self.client.post(reverse("club:club_members", kwargs={"club_id":4}), {"user": 2, "role": 4})
|
||||
self.client.post(reverse("club:club_members", kwargs={"club_id":self.bdf.id}), {"user": 2, "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(response.status_code == 200)
|
||||
self.assertFalse("<li>Woenzel'UT - skia - Secrétaire</li>" in str(response.content))
|
||||
self.assertFalse("skia - Secrétaire</li>" 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":4}), {"user": 2, "role": 10})
|
||||
self.client.post(reverse("club:club_members", kwargs={"club_id":self.bdf.id}), {"user": 2, "role": 10})
|
||||
self.client.login(username='skia', password='plop')
|
||||
self.client.post(reverse("club:club_members", kwargs={"club_id":4}), {"user": 7, "role": 9})
|
||||
response = self.client.get(reverse("club:club_members", kwargs={"club_id":4}))
|
||||
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("<li>Woenzel'UT - rbatsbak - Vice-Pr" in str(response.content))
|
||||
self.assertTrue("rbatsbak - Vice-Pr" 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":4}), {"user": 7, "role": 3})
|
||||
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":4}), {"user": 4, "role": 10})
|
||||
response = self.client.post(reverse("club:club_members", kwargs={"club_id":self.bdf.id}), {"user": 4, "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))
|
||||
|
||||
|
@ -447,7 +447,10 @@ class Page(models.Model):
|
||||
return '/'.join([self.parent.get_full_name(), self.name])
|
||||
|
||||
def get_display_name(self):
|
||||
return self.revisions.last().title
|
||||
try:
|
||||
return self.revisions.last().title
|
||||
except:
|
||||
return self.name
|
||||
|
||||
class PageRev(models.Model):
|
||||
"""
|
||||
|
@ -13,7 +13,7 @@
|
||||
<p>{% trans %}Born: {% endtrans %}{{ profile.date_of_birth|date("d/m/Y") }}</p>
|
||||
</div>
|
||||
|
||||
{% if user.membership.filter(end_date=None).exists() %}
|
||||
{% if user.membership.filter(end_date=None).exists() or user.is_in_group(settings.SITH_MAIN_BOARD_GROUP) %}
|
||||
{# if the user is member of a club, he can view the subscription state #}
|
||||
<p>
|
||||
{% if get_subscriber(profile).is_subscribed() %}
|
||||
|
@ -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('Please try again' in str(response.content))
|
||||
self.assertTrue('<ul class="errorlist nonfield">' in str(response.content))
|
||||
|
||||
class PageHandlingTest(TestCase):
|
||||
def setUp(self):
|
||||
@ -188,7 +188,7 @@ class PageHandlingTest(TestCase):
|
||||
})
|
||||
response = self.client.get(reverse('core:page', kwargs={'page_name': 'guy'}))
|
||||
self.assertTrue(response.status_code == 200)
|
||||
self.assertTrue("<strong>guy</strong>" in str(response.content))
|
||||
self.assertTrue('<a href="/page/guy/hist">' in str(response.content))
|
||||
|
||||
def test_create_child_page_ok(self):
|
||||
"""
|
||||
@ -206,7 +206,7 @@ class PageHandlingTest(TestCase):
|
||||
})
|
||||
response = self.client.get(reverse('core:page', kwargs={'page_name': 'guy/bibou'}))
|
||||
self.assertTrue(response.status_code == 200)
|
||||
self.assertTrue("<strong>guy/bibou</strong>" in str(response.content))
|
||||
self.assertTrue('<a href="/page/guy/bibou/">' in str(response.content))
|
||||
|
||||
def test_access_child_page_ok(self):
|
||||
"""
|
||||
@ -227,7 +227,6 @@ class PageHandlingTest(TestCase):
|
||||
})
|
||||
response = self.client.get(reverse('core:page', kwargs={'page_name': 'guy/bibou'}))
|
||||
self.assertTrue(response.status_code == 200)
|
||||
#self.assertTrue('PAGE_FOUND : Bibou' in str(response.content))
|
||||
|
||||
def test_access_page_not_found(self):
|
||||
"""
|
||||
@ -235,7 +234,7 @@ class PageHandlingTest(TestCase):
|
||||
"""
|
||||
response = self.client.get(reverse('core:page', kwargs={'page_name': 'swagg'}))
|
||||
self.assertTrue(response.status_code == 200)
|
||||
self.assertTrue('<a href="/page/create?page=swagg">Create it?</a>' in str(response.content))
|
||||
self.assertTrue('<a href="/page/create?page=swagg">' in str(response.content))
|
||||
|
||||
def test_create_page_markdown_safe(self):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user