From 9b5ad96aaaf10a343b0d883f2bbe63f68dfc1b43 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Sun, 17 Jan 2021 13:57:50 +0100 Subject: [PATCH] Fix broken tests --- .../participation/participation_detail.html | 8 ++++- .../templates/participation/team_detail.html | 9 ++++-- apps/participation/tests.py | 30 +++++++++++++++++++ apps/registration/tests.py | 29 +++++++++++++++--- 4 files changed, 69 insertions(+), 7 deletions(-) diff --git a/apps/participation/templates/participation/participation_detail.html b/apps/participation/templates/participation/participation_detail.html index aa57347..0b824b5 100644 --- a/apps/participation/templates/participation/participation_detail.html +++ b/apps/participation/templates/participation/participation_detail.html @@ -14,7 +14,13 @@
{{ participation.team }}
{% trans "Tournament:" %}
-
{{ participation.tournament }}
+
+ {% if participation.tournament %} + {{ participation.tournament }} + {% else %} + {% trans "any" %} + {% endif %} +
{% trans "Solutions:" %}
diff --git a/apps/participation/templates/participation/team_detail.html b/apps/participation/templates/participation/team_detail.html index 16cad3a..eecaaf0 100644 --- a/apps/participation/templates/participation/team_detail.html +++ b/apps/participation/templates/participation/team_detail.html @@ -41,8 +41,13 @@
{% trans "Tournament:" %}
- {% trans "any" as any %} -
{{ team.participation.tournament|default:any }}
+
+ {% if team.participation.tournament %} + {{ team.participation.tournament }} + {% else %} + {% trans "any" %} + {% endif %} +
{% trans "Photo authorizations:" %}
diff --git a/apps/participation/tests.py b/apps/participation/tests.py index c62b90a..245e5f1 100644 --- a/apps/participation/tests.py +++ b/apps/participation/tests.py @@ -210,6 +210,8 @@ class TestStudentParticipation(TestCase): email_confirmed=True, team=self.team, photo_authorization="authorization/photo/mai-linh", + health_sheet="authorization/health/mai-linh", + parental_authorization="authorization/parental/mai-linh", ) third_user = User.objects.create( @@ -226,8 +228,34 @@ class TestStudentParticipation(TestCase): email_confirmed=True, team=self.team, photo_authorization="authorization/photo/yohann", + health_sheet="authorization/health/yohann", + parental_authorization="authorization/parental/yohann", ) + fourth_user = User.objects.create( + first_name="tfjm", + last_name="tfjm", + email="tfjm@example.com", + password="tfjm", + ) + StudentRegistration.objects.create( + user=fourth_user, + student_class=10, + school="Sun", + give_contact_to_animath=False, + email_confirmed=True, + team=self.team, + photo_authorization="authorization/photo/tfjm", + health_sheet="authorization/health/tfjm", + parental_authorization="authorization/parental/tfjm", + ) + + self.coach.registration.team = self.team + self.coach.registration.health_sheet = "authorization/health/coach" + self.coach.registration.photo_authorization = "authorization/photo/coach" + self.coach.registration.email_confirmed = True + self.coach.registration.save() + self.client.force_login(self.superuser) # Admin users can't ask for validation resp = self.client.post(reverse("participation:team_detail", args=(self.team.pk,)), data=dict( @@ -251,6 +279,8 @@ class TestStudentParticipation(TestCase): self.assertEqual(resp.status_code, 200) self.user.registration.photo_authorization = "authorization/photo/ananas" + self.user.registration.health_sheet = "authorization/health/ananas" + self.user.registration.parental_authorization = "authorization/parental/ananas" self.user.registration.save() resp = self.client.get(reverse("participation:team_detail", args=(self.team.pk,))) diff --git a/apps/registration/tests.py b/apps/registration/tests.py index bd6c2f3..7fd391f 100644 --- a/apps/registration/tests.py +++ b/apps/registration/tests.py @@ -129,10 +129,18 @@ class TestRegistration(TestCase): role="participant", student_class=12, school="God", + birth_date="2000-01-01", + address="1 Rue de Rivoli, 75001 Paris, France", + phone_number="0123456789", + responsible_name="Toto", + responsible_phone="0123456789", + responsible_email="toto@example.com", give_contact_to_animath=False, )) self.assertRedirects(response, reverse("registration:email_validation_sent"), 302, 200) - self.assertTrue(User.objects.filter(email="toto@example.com").exists()) + self.assertTrue(User.objects.filter( + email="toto@example.com", + registration__participantregistration__studentregistration__responsible_name="Toto").exists()) # Email is already used response = self.client.post(reverse("registration:signup"), data=dict( @@ -144,6 +152,12 @@ class TestRegistration(TestCase): role="participant", student_class=12, school="God", + birth_date="2000-01-01", + address="1 Rue de Rivoli, 75001 Paris, France", + phone_number="0123456789", + responsible_name="Toto", + responsible_phone="0123456789", + responsible_email="toto@example.com", give_contact_to_animath=False, )) self.assertEqual(response.status_code, 200) @@ -158,6 +172,9 @@ class TestRegistration(TestCase): password1="azertyuiopazertyuiop", password2="azertyuiopazertyuiop", role="coach", + birth_date="1980-01-01", + address="1 Rue de Rivoli, 75001 Paris, France", + phone_number="0123456789", professional_activity="God", give_contact_to_animath=True, )) @@ -234,8 +251,11 @@ class TestRegistration(TestCase): self.student.registration.save() for user, data in [(self.user, dict(role="Bot")), - (self.student, dict(student_class=11, school="Sky")), - (self.coach, dict(professional_activity="God"))]: + (self.student, dict(student_class=11, school="Sky", birth_date="2001-01-01", + address="1 Rue de Rivoli, 75001 Paris, France", responsible_name="Toto", + responsible_email="toto@example.com")), + (self.coach, dict(professional_activity="God", birth_date="2001-01-01", + address="1 Rue de Rivoli, 75001 Paris, France"))]: response = self.client.get(reverse("registration:update_user", args=(user.pk,))) self.assertEqual(response.status_code, 200) @@ -333,7 +353,8 @@ class TestRegistration(TestCase): response = self.client.get(reverse("registration:update_user", args=(self.user.pk,))) self.assertEqual(response.status_code, 403) - response = self.client.get(reverse("registration:upload_user_photo_authorization", args=(self.user.pk,))) + response = self.client.get(reverse("registration:upload_user_photo_authorization", + args=(self.student.registration.pk,))) self.assertEqual(response.status_code, 403) response = self.client.get(reverse("photo_authorization", args=("inexisting-authorization",)))