diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c4a942e..5e8d54e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,7 +8,7 @@ py38: before_script: - apk add --no-cache libmagic - pip install tox --no-cache-dir - script: tox -e py38-django31 + script: tox -e py38 linters: stage: quality-assurance diff --git a/apps/participation/tests.py b/apps/participation/tests.py index b748b5c..4ea75e5 100644 --- a/apps/participation/tests.py +++ b/apps/participation/tests.py @@ -122,10 +122,19 @@ class TestStudentParticipation(TestCase): self.assertRedirects(response, reverse("participation:team_detail", args=(self.team.pk,)), 302, 200) self.assertTrue(Team.objects.filter(trigram="BBB", participation__problem=3).exists()) + def test_no_myparticipation_redirect_nomyparticipation(self): + response = self.client.get(reverse("participation:my_participation_detail")) + self.assertTrue(response.status_code, 200) + def test_participation_detail(self): self.user.registration.team = self.team self.user.registration.save() + response = self.client.get(reverse("participation:my_participation_detail")) + self.assertRedirects(response, + reverse("participation:participation_detail", args=(self.team.participation.pk,)), + 302, 200) + response = self.client.get(reverse("participation:participation_detail", args=(self.team.participation.pk,))) self.assertEqual(response.status_code, 200) diff --git a/apps/registration/tests.py b/apps/registration/tests.py index a81945d..f3c8e5e 100644 --- a/apps/registration/tests.py +++ b/apps/registration/tests.py @@ -145,6 +145,31 @@ class TestRegistration(TestCase): self.assertFalse(user.registration.email_confirmed) self.assertEqual(user.first_name, "Changed") + def test_upload_photo_authorization(self): + response = self.client.get(reverse("registration:upload_user_photo_authorization", + args=(self.student.registration.pk,))) + self.assertEqual(response.status_code, 200) + + # README is not a valid PDF file + response = self.client.post(reverse("registration:upload_user_photo_authorization", + args=(self.student.registration.pk,)), data=dict( + photo_authorization=open("README.md", "rb"), + )) + self.assertEqual(response.status_code, 200) + + response = self.client.post(reverse("registration:upload_user_photo_authorization", + args=(self.student.registration.pk,)), data=dict( + photo_authorization=open("corres2math/static/Autorisation de droit à l'image - majeur.pdf", "rb"), + )) + self.assertRedirects(response, reverse("registration:user_detail", args=(self.student.pk,)), 302, 200) + + self.student.registration.refresh_from_db() + self.assertTrue(self.student.registration.photo_authorization) + + response = self.client.get(reverse("photo_authorization", + args=(self.student.registration.photo_authorization.name.split('/')[-1],))) + self.assertEqual(response.status_code, 200) + def test_string_render(self): # TODO These string field tests will be removed when used in a template str(self.user.registration)