mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2025-02-06 12:53:03 +00:00
Test photo authorization upload
This commit is contained in:
parent
366f0c40a0
commit
3b73edd6b0
@ -8,7 +8,7 @@ py38:
|
|||||||
before_script:
|
before_script:
|
||||||
- apk add --no-cache libmagic
|
- apk add --no-cache libmagic
|
||||||
- pip install tox --no-cache-dir
|
- pip install tox --no-cache-dir
|
||||||
script: tox -e py38-django31
|
script: tox -e py38
|
||||||
|
|
||||||
linters:
|
linters:
|
||||||
stage: quality-assurance
|
stage: quality-assurance
|
||||||
|
@ -122,10 +122,19 @@ class TestStudentParticipation(TestCase):
|
|||||||
self.assertRedirects(response, reverse("participation:team_detail", args=(self.team.pk,)), 302, 200)
|
self.assertRedirects(response, reverse("participation:team_detail", args=(self.team.pk,)), 302, 200)
|
||||||
self.assertTrue(Team.objects.filter(trigram="BBB", participation__problem=3).exists())
|
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):
|
def test_participation_detail(self):
|
||||||
self.user.registration.team = self.team
|
self.user.registration.team = self.team
|
||||||
self.user.registration.save()
|
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,)))
|
response = self.client.get(reverse("participation:participation_detail", args=(self.team.participation.pk,)))
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
|
@ -145,6 +145,31 @@ class TestRegistration(TestCase):
|
|||||||
self.assertFalse(user.registration.email_confirmed)
|
self.assertFalse(user.registration.email_confirmed)
|
||||||
self.assertEqual(user.first_name, "Changed")
|
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):
|
def test_string_render(self):
|
||||||
# TODO These string field tests will be removed when used in a template
|
# TODO These string field tests will be removed when used in a template
|
||||||
str(self.user.registration)
|
str(self.user.registration)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user