Skip to content

Commit

Permalink
tests: add test comparing odt to png snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
CyanVoxel committed Oct 13, 2024
1 parent 91cf3ad commit 2edb11f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
Binary file added tagstudio/tests/fixtures/sample.odt
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions tagstudio/tests/qt/test_thumb_renderer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (C) 2024 Travis Abendshien (CyanVoxel).
# Licensed under the GPL-3.0 License.
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio

import io
from pathlib import Path

from PIL import Image
from src.qt.widgets.thumb_renderer import ThumbRenderer
from syrupy.extensions.image import PNGImageSnapshotExtension


def test_odt_preview(cwd, snapshot):
file_path: Path = cwd / "fixtures" / "sample.odt"
renderer = ThumbRenderer()
img: Image.Image = renderer._open_doc_thumb(file_path)

img_bytes = io.BytesIO()
img.save(img_bytes, format="PNG")
img_bytes.seek(0)
assert img_bytes.read() == snapshot(extension_class=PNGImageSnapshotExtension)

0 comments on commit 2edb11f

Please sign in to comment.