Add a test for the copy_exif function.

This commit is contained in:
Simon
2012-11-27 23:31:12 +01:00
parent 25b9f5966a
commit ec2be44146
4 changed files with 47 additions and 4 deletions

0
tests/__init__.py Normal file
View File

View File

@@ -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

45
tests/test_image.py Normal file
View File

@@ -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())

View File

@@ -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