diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_gallery.py b/tests/test_gallery.py index 6d24025..52d9f2f 100644 --- a/tests/test_gallery.py +++ b/tests/test_gallery.py @@ -1,4 +1,3 @@ -#! /usr/bin/env python2 # -*- coding:utf-8 -*- import os @@ -6,7 +5,7 @@ import os try: import unittest2 as unittest except ImportError: - import unittest + import unittest # NOQA from sigal.gallery import Gallery, get_metadata from sigal.settings import read_settings diff --git a/tests/test_image.py b/tests/test_image.py new file mode 100644 index 0000000..75fcb7c --- /dev/null +++ b/tests/test_image.py @@ -0,0 +1,45 @@ +# -*- coding:utf-8 -*- + +import os +from tempfile import mkdtemp +from shutil import rmtree + +try: + import unittest2 as unittest +except ImportError: + import unittest # NOQA + +try: + import pyexiv2 +except ImportError: + pyexiv2 = False + +from sigal.image import copy_exif, Image + +CURRENT_DIR = os.path.dirname(__file__) + + +@unittest.skipUnless(pyexiv2, "pyexiv2 isn't installed") +class TestExif(unittest.TestCase): + "Test the copy of exif metadata with pyexiv2." + + def setUp(self): + self.temp_path = mkdtemp() + self.srcfile = os.path.join(CURRENT_DIR, + 'sample/dir2/exo20101028-b-full.jpg') + self.dstfile = os.path.join(self.temp_path, 'exo20101028-b-full.jpg') + + img = Image(self.srcfile) + img.save(self.dstfile) + copy_exif(self.srcfile, self.dstfile) + + def tearDown(self): + rmtree(self.temp_path) + + def test_exif(self): + src = pyexiv2.ImageMetadata(self.srcfile) + dst = pyexiv2.ImageMetadata(self.dstfile) + src.read() + dst.read() + + self.assertListEqual(src.keys(), dst.keys()) diff --git a/tests/test_settings.py b/tests/test_settings.py index b26ab80..8efee57 100644 --- a/tests/test_settings.py +++ b/tests/test_settings.py @@ -1,4 +1,3 @@ -#! /usr/bin/env python2 # -*- coding:utf-8 -*- import os @@ -6,7 +5,7 @@ import os try: import unittest2 as unittest except ImportError: - import unittest + import unittest # NOQA from sigal.settings import read_settings, get_size