aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorOlivier Tilloy <olivier@tilloy.net>2010-01-22 21:00:13 +0100
committerOlivier Tilloy <olivier@tilloy.net>2010-01-22 21:00:13 +0100
commit24b9261f486f68db6166a28f07af510a6830d17b (patch)
tree2458966c5f4ee43c44705a7a0783ecd13ec7b80c /test
parentbdd8941477e703ccd0240c68767c972f7d81afbe (diff)
downloadpyexiv2-24b9261f486f68db6166a28f07af510a6830d17b.tar.gz
Copy metadata to another image.
From an original patch by Ilpo Nyyssönen (http://iny.iki.fi/).
Diffstat (limited to 'test')
-rw-r--r--test/metadata.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/metadata.py b/test/metadata.py
index 235fafa..ac0eae9 100644
--- a/test/metadata.py
+++ b/test/metadata.py
@@ -161,6 +161,14 @@ class ImageMock(object):
except KeyError:
pass
+ def copyMetadata(self, other, exif=True, iptc=True, xmp=True):
+ if exif:
+ other.tags['exif'] = self.tags['exif']
+ if iptc:
+ other.tags['iptc'] = self.tags['iptc']
+ if xmp:
+ other.tags['xmp'] = self.tags['xmp']
+
class TestImageMetadata(unittest.TestCase):
@@ -694,3 +702,32 @@ class TestImageMetadata(unittest.TestCase):
for key in keys:
self.failUnlessRaises(KeyError, self.metadata.__delitem__, key)
+ ####################
+ # Test metadata copy
+ ####################
+
+ def _set_up_other(self):
+ self.other = ImageMetadata('nofile')
+ self.other._instantiate_image = lambda filename: ImageMock(filename)
+
+ def test_copy_metadata(self):
+ self.metadata.read()
+ self._set_exif_tags()
+ self._set_iptc_tags()
+ self._set_xmp_tags()
+ self._set_up_other()
+ self.other.read()
+ self.failUnlessEqual(self.other.exif_keys, [])
+ self.failUnlessEqual(self.other.iptc_keys, [])
+ self.failUnlessEqual(self.other.xmp_keys, [])
+ self.metadata.copy(self.other)
+
+ # The actual test is here, the rest of the functionality being mocked...
+ for family in ('exif', 'iptc', 'xmp'):
+ self.failUnlessEqual(self.other._keys[family], None)
+ self.failUnlessEqual(self.other._tags[family], {})
+
+ self.failUnlessEqual(self.other.exif_keys, self.metadata.exif_keys)
+ self.failUnlessEqual(self.other.iptc_keys, self.metadata.iptc_keys)
+ self.failUnlessEqual(self.other.xmp_keys, self.metadata.xmp_keys)
+