mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2025-06-22 03:18:22 +02:00
Test video upload
This commit is contained in:
@ -122,6 +122,32 @@ 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_participation_detail(self):
|
||||
self.user.registration.team = self.team
|
||||
self.user.registration.save()
|
||||
|
||||
response = self.client.get(reverse("participation:participation_detail", args=(self.team.participation.pk,)))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_upload_video(self):
|
||||
self.user.registration.team = self.team
|
||||
self.user.registration.save()
|
||||
|
||||
response = self.client.get(reverse("participation:upload_video", args=(self.team.participation.solution.pk,)))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
response = self.client.post(reverse("participation:upload_video", args=(self.team.participation.solution.pk,)),
|
||||
data=dict(link="https://youtube.com/watch?v=73nsrixx7eI"))
|
||||
self.assertRedirects(response,
|
||||
reverse("participation:participation_detail", args=(self.team.participation.id,)),
|
||||
302, 200)
|
||||
self.team.participation.refresh_from_db()
|
||||
self.assertEqual(self.team.participation.solution.platform, "youtube")
|
||||
self.assertEqual(self.team.participation.solution.youtube_code, "73nsrixx7eI")
|
||||
|
||||
response = self.client.get(reverse("participation:participation_detail", args=(self.team.participation.pk,)))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
|
||||
class TestAdminForbidden(TestCase):
|
||||
def setUp(self) -> None:
|
||||
|
@ -147,7 +147,7 @@ class UploadVideoView(LoginRequiredMixin, UpdateView):
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
user = request.user
|
||||
if user.registration.is_admin or user.registration.participates\
|
||||
and user.registration.team.participation.pk == self.object.participation.pk:
|
||||
and user.registration.team.participation.pk == self.get_object().participation.pk:
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
raise PermissionDenied
|
||||
|
||||
|
Reference in New Issue
Block a user