summaryrefslogtreecommitdiff
path: root/server/szurubooru/tests/func/test_posts.py
diff options
context:
space:
mode:
authorRuin0x11 <ipickering2@gmail.com>2021-05-07 21:20:42 -0700
committerRuin0x11 <ipickering2@gmail.com>2021-05-07 21:20:42 -0700
commit7e27df835c32bdc8b7c4a2c7570df5a02c7c4b9d (patch)
tree831a1163df79de5844cc1a6d2321643a42e78602 /server/szurubooru/tests/func/test_posts.py
parent169593ea3689e50388dbda13984cbb9bc3d7ce1c (diff)
Add AVIF/HEIF/HEIC upload support
Diffstat (limited to 'server/szurubooru/tests/func/test_posts.py')
-rw-r--r--server/szurubooru/tests/func/test_posts.py67
1 files changed, 67 insertions, 0 deletions
diff --git a/server/szurubooru/tests/func/test_posts.py b/server/szurubooru/tests/func/test_posts.py
index 6139555..609949f 100644
--- a/server/szurubooru/tests/func/test_posts.py
+++ b/server/szurubooru/tests/func/test_posts.py
@@ -394,6 +394,41 @@ def test_update_post_source_with_too_long_string():
),
(
False,
+ "avif.avif",
+ "image/avif",
+ model.Post.TYPE_IMAGE,
+ "1_244c8840887984c4.avif",
+ ),
+ (
+ False,
+ "avif-avis.avif",
+ "image/avif",
+ model.Post.TYPE_IMAGE,
+ "1_244c8840887984c4.avif",
+ ),
+ (
+ False,
+ "heic.heic",
+ "image/heic",
+ model.Post.TYPE_IMAGE,
+ "1_244c8840887984c4.heic",
+ ),
+ (
+ False,
+ "heic-heix.heic",
+ "image/heic",
+ model.Post.TYPE_IMAGE,
+ "1_244c8840887984c4.heic",
+ ),
+ (
+ False,
+ "heif.heif",
+ "image/heif",
+ model.Post.TYPE_IMAGE,
+ "1_244c8840887984c4.heif",
+ ),
+ (
+ False,
"gif-animated.gif",
"image/gif",
model.Post.TYPE_ANIMATION,
@@ -699,6 +734,38 @@ def test_update_post_content_leaving_custom_thumbnail(
assert os.path.exists(generated_path)
+@pytest.mark.parametrize("filename", ("avif.avif", "heic.heic", "heif.heif"))
+def test_update_post_content_convert_heif_to_png_when_processing(
+ tmpdir, config_injector, read_asset, post_factory, filename
+):
+ config_injector(
+ {
+ "data_dir": str(tmpdir.mkdir("data")),
+ "thumbnails": {
+ "post_width": 300,
+ "post_height": 300,
+ },
+ "secret": "test",
+ "allow_broken_uploads": False,
+ }
+ )
+ post = post_factory(id=1)
+ db.session.add(post)
+ posts.update_post_content(post, read_asset(filename))
+ posts.update_post_thumbnail(post, read_asset(filename))
+ db.session.flush()
+ generated_path = (
+ "{}/data/generated-thumbnails/".format(tmpdir)
+ + "1_244c8840887984c4.jpg"
+ )
+ source_path = (
+ "{}/data/posts/custom-thumbnails/".format(tmpdir)
+ + "1_244c8840887984c4.dat"
+ )
+ assert os.path.exists(source_path)
+ assert os.path.exists(generated_path)
+
+
def test_update_post_tags(tag_factory):
post = model.Post()
with patch("szurubooru.func.tags.get_or_create_tags_by_names"):