Fix broken tests

This commit is contained in:
Yohann D'ANELLO 2021-01-17 13:57:50 +01:00
parent c151ff3611
commit 9b5ad96aaa
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
4 changed files with 69 additions and 7 deletions

View File

@ -14,7 +14,13 @@
<dd class="col-sm-10"><a href="{% url "participation:team_detail" pk=participation.team.pk %}">{{ participation.team }}</a></dd>
<dt class="col-sm-2">{% trans "Tournament:" %}</dt>
<dd class="col-sm-10"><a href="{% url "participation:tournament_detail" pk=participation.tournament.pk %}">{{ participation.tournament }}</a></dd>
<dd class="col-sm-10">
{% if participation.tournament %}
<a href="{% url "participation:tournament_detail" pk=participation.tournament.pk %}">{{ participation.tournament }}</a>
{% else %}
{% trans "any" %}
{% endif %}
</dd>
<dt class="col-sm-2">{% trans "Solutions:" %}</dt>
<dd class="col-sm-10">

View File

@ -41,8 +41,13 @@
</dd>
<dt class="col-sm-6 text-right">{% trans "Tournament:" %}</dt>
{% trans "any" as any %}
<dd class="col-sm-6"><a href="{% url "participation:tournament_detail" pk=team.participation.tournament.pk %}">{{ team.participation.tournament|default:any }}</a></dd>
<dd class="col-sm-6">
{% if team.participation.tournament %}
<a href="{% url "participation:tournament_detail" pk=team.participation.tournament.pk %}">{{ team.participation.tournament }}</a>
{% else %}
{% trans "any" %}
{% endif %}
</dd>
<dt class="col-sm-6 text-right">{% trans "Photo authorizations:" %}</dt>
<dd class="col-sm-6">

View File

@ -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,)))

View File

@ -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",)))