mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2025-02-06 12:13:01 +00:00
Test participation admin pages
This commit is contained in:
parent
682ef05110
commit
7ae2b152c6
@ -1,9 +1,11 @@
|
|||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
from django.contrib.contenttypes.models import ContentType
|
||||||
|
from django.contrib.sites.models import Site
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from registration.models import StudentRegistration
|
from registration.models import StudentRegistration
|
||||||
|
|
||||||
from .models import Team
|
from .models import Participation, Question, Team, Video
|
||||||
|
|
||||||
|
|
||||||
class TestStudentParticipation(TestCase):
|
class TestStudentParticipation(TestCase):
|
||||||
@ -27,11 +29,72 @@ class TestStudentParticipation(TestCase):
|
|||||||
access_code="azerty",
|
access_code="azerty",
|
||||||
grant_animath_access_videos=True,
|
grant_animath_access_videos=True,
|
||||||
)
|
)
|
||||||
|
self.question = Question.objects.create(participation=self.team.participation,
|
||||||
|
question="Pourquoi l'existence précède l'essence ?")
|
||||||
self.client.force_login(self.user)
|
self.client.force_login(self.user)
|
||||||
|
|
||||||
# TODO Remove these lines
|
def test_admin_pages(self):
|
||||||
str(self.team)
|
"""
|
||||||
str(self.team.participation)
|
Load Django-admin pages.
|
||||||
|
"""
|
||||||
|
superuser = User.objects.create_superuser(
|
||||||
|
username="admin",
|
||||||
|
email="admin@example.com",
|
||||||
|
password="toto1234",
|
||||||
|
)
|
||||||
|
self.client.force_login(superuser)
|
||||||
|
|
||||||
|
# Test team pages
|
||||||
|
response = self.client.get(reverse("admin:index") + "participation/team/")
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
response = self.client.get(reverse("admin:index")
|
||||||
|
+ f"participation/team/{self.team.pk}/change/")
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
response = self.client.get(reverse("admin:index") +
|
||||||
|
f"r/{ContentType.objects.get_for_model(Team).id}/"
|
||||||
|
f"{self.team.pk}/")
|
||||||
|
self.assertRedirects(response, "http://" + Site.objects.get().domain +
|
||||||
|
str(self.team.get_absolute_url()), 302, 200)
|
||||||
|
|
||||||
|
# Test participation pages
|
||||||
|
self.team.participation.valid = True
|
||||||
|
self.team.participation.save()
|
||||||
|
response = self.client.get(reverse("admin:index") + "participation/participation/")
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
response = self.client.get(reverse("admin:index")
|
||||||
|
+ f"participation/participation/{self.team.participation.pk}/change/")
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
response = self.client.get(reverse("admin:index") +
|
||||||
|
f"r/{ContentType.objects.get_for_model(Participation).id}/"
|
||||||
|
f"{self.team.participation.pk}/")
|
||||||
|
self.assertRedirects(response, "http://" + Site.objects.get().domain +
|
||||||
|
str(self.team.participation.get_absolute_url()), 302, 200)
|
||||||
|
|
||||||
|
# Test video pages
|
||||||
|
response = self.client.get(reverse("admin:index") + "participation/video/")
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
response = self.client.get(reverse("admin:index")
|
||||||
|
+ f"participation/video/{self.team.participation.solution.pk}/change/")
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
# Test question pages
|
||||||
|
response = self.client.get(reverse("admin:index") + "participation/question/")
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
response = self.client.get(reverse("admin:index")
|
||||||
|
+ f"participation/question/{self.question.pk}/change/")
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
# Test phase pages
|
||||||
|
response = self.client.get(reverse("admin:index") + "participation/phase/")
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
response = self.client.get(reverse("admin:index")
|
||||||
|
+ f"participation/phase/1/change/")
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
def test_create_team(self):
|
def test_create_team(self):
|
||||||
"""
|
"""
|
||||||
@ -62,6 +125,7 @@ class TestStudentParticipation(TestCase):
|
|||||||
trigram="TET",
|
trigram="TET",
|
||||||
grant_animath_access_videos=False,
|
grant_animath_access_videos=False,
|
||||||
))
|
))
|
||||||
|
self.assertEqual(response.status_code, 403)
|
||||||
|
|
||||||
def test_join_team(self):
|
def test_join_team(self):
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user