From: Joshua May Date: Mon, 14 Oct 2019 01:20:21 +0000 (-0700) Subject: We got our first snapshot tests for HTML rendering X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=571b9372a977d6836aed8dfacb947a1bd423e6ce;p=sirius.git We got our first snapshot tests for HTML rendering --- diff --git a/requirements.txt b/requirements.txt index 8ab88a2..93e819e 100755 --- a/requirements.txt +++ b/requirements.txt @@ -36,5 +36,6 @@ requests==2.22.0 requests-oauthlib==1.2.0 selenium==3.141.0 six==1.12.0 +git+git://github.com/syrusakbary/snapshottest.git@4ac2b4fb09e9e7728bebb11967c164a914775d1d#snapshottest twitter==1.18.0 websocket-client==0.56.0 diff --git a/sirius/coding/snapshots/__init__.py b/sirius/coding/snapshots/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/sirius/coding/snapshots/snap_test_image_coding.py b/sirius/coding/snapshots/snap_test_image_coding.py new file mode 100644 index 0000000..d10dcb1 --- /dev/null +++ b/sirius/coding/snapshots/snap_test_image_coding.py @@ -0,0 +1,11 @@ +# -*- coding: utf-8 -*- +# snapshottest: v1 - https://goo.gl/zC4yUc +from __future__ import unicode_literals + +from snapshottest import Snapshot +from snapshottest.file import FileSnapshot + + +snapshots = Snapshot() + +snapshots['ImageSnapshotCase::test_snapshot_fixtures hello_world'] = FileSnapshot('snap_test_image_coding/ImageSnapshotCase::test_snapshot_fixtures hello_world.png') diff --git a/sirius/coding/snapshots/snap_test_image_coding/ImageSnapshotCase::test_snapshot_fixtures hello_world.png b/sirius/coding/snapshots/snap_test_image_coding/ImageSnapshotCase::test_snapshot_fixtures hello_world.png new file mode 100644 index 0000000..6c11f48 Binary files /dev/null and b/sirius/coding/snapshots/snap_test_image_coding/ImageSnapshotCase::test_snapshot_fixtures hello_world.png differ diff --git a/sirius/coding/test_image_coding.py b/sirius/coding/test_image_coding.py index 081b8af..2d529c7 100644 --- a/sirius/coding/test_image_coding.py +++ b/sirius/coding/test_image_coding.py @@ -1,5 +1,9 @@ +import os +from tempfile import TemporaryDirectory from PIL import Image, ImageDraw import unittest +import snapshottest +from snapshottest.file import FileSnapshot from sirius.coding import image_encoding @@ -21,6 +25,21 @@ class ImageCase(unittest.TestCase): self.assertEquals(image.size[0], 384) self.assertEquals(image.size[1], 100) +class ImageSnapshotCase(snapshottest.TestCase): + def test_snapshot_fixtures(self): + fixtures = { + 'hello_world': 'Hello, world!', + } + + for name, html in fixtures.items(): + with TemporaryDirectory() as tmpdir: + data = image_encoding.html_to_png(html) + image = Image.open(data) + + temp_file_name = os.path.join(tmpdir, '%s.png' % name) + image.save(temp_file_name, format='PNG') + self.assertMatchSnapshot(FileSnapshot(temp_file_name), name) + class PipeTestCase(unittest.TestCase): def test_specific_image_rle(self):