Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supprime le fichier .svgz généré pendant un test #6463

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions zds/gallery/api/tests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from uuid import uuid4

from django.core.cache import caches
Expand Down Expand Up @@ -281,21 +282,24 @@ def test_post_add_image(self):
def test_post_fail_add_image_not_an_image(self):
title = "un super titre pour une image"
legend = "une super legende aussi"
file_id = str(uuid4())
filename = str(uuid4()) + ".svgz"
# generate a bare empty file so that the test continues and sends error message
with open(file_id + ".svgz", "w"):
with open(filename, "w"):
pass
response = self.client.post(
reverse("api:gallery:list-images", kwargs={"pk_gallery": self.gallery.pk}),
{
"title": title,
"legend": legend,
"physical": open(file_id + ".svgz", "rb"),
},
format="multipart",
)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertEqual(Image.objects.filter(gallery=self.gallery).count(), 1)
try:
response = self.client.post(
reverse("api:gallery:list-images", kwargs={"pk_gallery": self.gallery.pk}),
{
"title": title,
"legend": legend,
"physical": open(filename, "rb"),
},
format="multipart",
)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertEqual(Image.objects.filter(gallery=self.gallery).count(), 1)
finally:
os.remove(filename)

def test_post_can_add_image_svg_image(self):
title = "un super titre pour une image svg"
Expand Down