From 571b9372a977d6836aed8dfacb947a1bd423e6ce Mon Sep 17 00:00:00 2001 From: Joshua May Date: Sun, 13 Oct 2019 18:20:21 -0700 Subject: [PATCH] We got our first snapshot tests for HTML rendering --- requirements.txt | 1 + sirius/coding/snapshots/__init__.py | 0 .../snapshots/snap_test_image_coding.py | 11 ++++++++++ ...se::test_snapshot_fixtures hello_world.png | Bin 0 -> 1297 bytes sirius/coding/test_image_coding.py | 19 ++++++++++++++++++ 5 files changed, 31 insertions(+) create mode 100644 sirius/coding/snapshots/__init__.py create mode 100644 sirius/coding/snapshots/snap_test_image_coding.py create mode 100644 sirius/coding/snapshots/snap_test_image_coding/ImageSnapshotCase::test_snapshot_fixtures hello_world.png 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 0000000000000000000000000000000000000000..6c11f48d75c23a74f7e45085e1f2fbda3edb5280 GIT binary patch literal 1297 zcmV+s1@8KZP)%77f}H^g`PTq@qWr&r1r_SK85r=gcX-}fzb^rf8S92uNmf5%M+0B_ z_0>`S6`pr*wHqiRl1HA^=;6RRkH3KpZ~zYi7e?hy1zxC7&y#*n>@wi<9Bmj+vicG0 z0q*qpP?SHz!=@^y*b)YYjsgPs~@pl(e-!& z=<{&r7`979WUuAjk4{oyIzNt21v-Ikz*b-taPTPFbO7+E-=6@V0t<8Ay9Aq5`hh2a zl~H;FP!Fu|^m4yv7Vwro>qp>K;8>stT#jv1Z3JEhb^|w-dG=yp6EFyLdtUta`Od?A zVZsv;`Nu=pVD=8SmmNO0QaS@@01DXP_YrUj@QGhr<@I#%@4fSvD4hY+0qsMLF781U7s5dETato<85poagl)3A6%#c$?<{*Lm3;*jCrtsDJ%_-#r=qxYEOLBY#`r^z4@~p8^mMHz%<}%?3+WnzF;@- z6E<0hh}2wRjO*La!_~l=D8C7qoa6p5xXz67zQP9d0=9=gk{_`B`ip^wy{>iGc2Xy{ zntvtZc^`W`9C+t>7TBZ`!aB0gMdG$?%UQ38NLA(i1`x`n2gUgQdTgZ(whc4Uqx_)7!*22kburOrNhuJh7bB-uRFo^wx?mQK_=Ls|1`GhecsD2^=pqrb$sS| zXJh;1-JZU|uV3%!n>^i$ZKv!6PA=2t36u_l!^G2#t@vj|0F$Eo()|dBzTX13MCm@@Dlc=XKmWcmZ59z3ceaxKOWg>rFHnT2feS` zfs3$j9=}BG+k(B$n$?d(fe)jyeNo@%`*W`LXFOA(%_1WEyaKkOo;p&&3R-~E$o?Ne zt=OvktP1x}X81PIB;b%TWsBJF0gmUtor_HIPm%1tHHello, 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): -- 2.47.3