+++ /dev/null
-# -*- 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')
--- /dev/null
+# -*- 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['ImageCodingSnapshotCase::test_snapshot_fixtures hello_world'] = FileSnapshot('snap_test_image_coding_snapshots/ImageCodingSnapshotCase::test_snapshot_fixtures hello_world.png')
+
+snapshots['ImageCodingSnapshotCase::test_snapshot_template_fixtures hello_world'] = FileSnapshot('snap_test_image_coding_snapshots/ImageCodingSnapshotCase::test_snapshot_template_fixtures hello_world.png')
-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
-
class ImageCase(unittest.TestCase):
def test_normal_text(self):
data = image_encoding.html_to_png(
self.assertEquals(image.size[0], 384)
self.assertEquals(image.size[1], 100)
-class ImageSnapshotCase(snapshottest.TestCase):
- def test_snapshot_fixtures(self):
- fixtures = {
- 'hello_world': '<html><body>Hello, world!</body></html>',
- }
-
- 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):
--- /dev/null
+import os
+from tempfile import TemporaryDirectory
+from PIL import Image
+
+import snapshottest
+from snapshottest.file import FileSnapshot
+
+from sirius.coding import image_encoding
+from sirius.coding import templating
+
+
+class ImageCodingSnapshotCase(snapshottest.TestCase):
+ def _check_html(self, name, html):
+ print('Cheking fixture named: %s' % name)
+
+ 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)
+
+ def test_snapshot_fixtures(self):
+ fixtures = {
+ 'hello_world': '<html><body>Hello, world!</body></html>',
+ }
+
+ for name, html in fixtures.items():
+ self._check_html(name, html)
+
+ def test_snapshot_template_fixtures(self):
+ fixtures = {
+ 'hello_world': '<p>Hello, world!</p>',
+ }
+
+ for name, snippet in fixtures.items():
+ self._check_html(name, templating.default_template(snippet, 'anonymous'))
\ No newline at end of file