mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2024-12-05 01:26:54 +00:00
Test video upload
This commit is contained in:
parent
4b8ed14180
commit
366f0c40a0
@ -2,7 +2,7 @@ stages:
|
||||
- test
|
||||
- quality-assurance
|
||||
|
||||
py38-django31:
|
||||
py38:
|
||||
stage: test
|
||||
image: python:3-alpine
|
||||
before_script:
|
||||
|
@ -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
|
||||
|
||||
|
@ -4,7 +4,7 @@ from corres2math.tokens import email_validation_token
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.exceptions import ValidationError, PermissionDenied
|
||||
from django.core.exceptions import PermissionDenied, ValidationError
|
||||
from django.db import transaction
|
||||
from django.http import FileResponse, Http404
|
||||
from django.shortcuts import redirect, resolve_url
|
||||
|
Loading…
Reference in New Issue
Block a user