mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2025-06-21 23:58:21 +02:00
Test photo authorization upload
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user