Skip to content

Commit

Permalink
use pytest raises
Browse files Browse the repository at this point in the history
  • Loading branch information
NC-jsAhonen committed Feb 3, 2025
1 parent 91e8d10 commit 412ad4a
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions forms/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.contrib.auth.models import Permission
from django.core.files.uploadedfile import SimpleUploadedFile
from django.http import FileResponse
from django.urls import reverse
from django.urls import NoReverseMatch, reverse
from django.utils import timezone
from faker import Faker

Expand Down Expand Up @@ -511,12 +511,8 @@ def test_attachment_upload_and_download_public(
assert Attachment.objects.filter(answer=response.json()["id"]).exists()

# Public endpoint should not allow getting attachments
error = None
try:
with pytest.raises(NoReverseMatch):
url = reverse("v1:pub_answer-attachments", kwargs={"pk": response.json()["id"]})
except Exception as e:
error = type(e).__name__
assert error == "NoReverseMatch"

# Public endpoint should not allow downloading attachments
url = reverse("v1:pub_attachment-download", kwargs={"pk": attachment_id})
Expand Down

0 comments on commit 412ad4a

Please sign in to comment.