mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2025-02-16 11:05:15 +00:00
Add test for special character in cover filename
This commit is contained in:
parent
f721289b1d
commit
bd95bcd50b
1 changed files with 21 additions and 0 deletions
|
@ -1,7 +1,13 @@
|
|||
"""test bookwyrm user export functions"""
|
||||
import datetime
|
||||
from io import BytesIO
|
||||
import pathlib
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
from PIL import Image
|
||||
|
||||
from django.core.files.base import ContentFile
|
||||
from django.utils import timezone
|
||||
from django.test import TestCase
|
||||
|
||||
|
@ -86,6 +92,15 @@ class BookwyrmExportJob(TestCase):
|
|||
title="Example Edition", parent_work=self.work
|
||||
)
|
||||
|
||||
# edition cover
|
||||
image_file = pathlib.Path(__file__).parent.joinpath(
|
||||
"../../static/images/default_avi.jpg"
|
||||
)
|
||||
image = Image.open(image_file)
|
||||
output = BytesIO()
|
||||
image.save(output, format=image.format)
|
||||
self.edition.cover.save("tèst.jpg", ContentFile(output.getvalue()))
|
||||
|
||||
self.edition.authors.add(self.author)
|
||||
|
||||
# readthrough
|
||||
|
@ -160,6 +175,7 @@ class BookwyrmExportJob(TestCase):
|
|||
self.assertIsNotNone(self.job.export_json["books"])
|
||||
self.assertEqual(len(self.job.export_json["books"]), 1)
|
||||
book = self.job.export_json["books"][0]
|
||||
|
||||
self.assertEqual(book["work"]["id"], self.work.remote_id)
|
||||
self.assertEqual(len(book["authors"]), 1)
|
||||
self.assertEqual(len(book["shelves"]), 1)
|
||||
|
@ -169,6 +185,11 @@ class BookwyrmExportJob(TestCase):
|
|||
self.assertEqual(len(book["quotations"]), 1)
|
||||
self.assertEqual(len(book["readthroughs"]), 1)
|
||||
|
||||
self.assertEqual(book["edition"]["id"], self.edition.remote_id)
|
||||
self.assertEqual(
|
||||
book["edition"]["cover"]["url"], f"images/{self.edition.cover.name}"
|
||||
)
|
||||
|
||||
def test_start_export_task(self):
|
||||
"""test saved list task saves initial json and data"""
|
||||
|
||||
|
|
Loading…
Reference in a new issue