aboutsummaryrefslogtreecommitdiffstats
path: root/unittest/metadata.py
diff options
context:
space:
mode:
authorOlivier Tilloy <olivier@tilloy.net>2009-04-22 09:55:42 +0200
committerOlivier Tilloy <olivier@tilloy.net>2009-04-22 09:55:42 +0200
commitfc159fa96a9a0d77f21891659e0ea8bc5b3b9f66 (patch)
treeb0c368c9f07fbba01b75180637963cbe6437d87a /unittest/metadata.py
parent80c93ece679e312215acb222e3875bcd72044fa1 (diff)
downloadpyexiv2-fc159fa96a9a0d77f21891659e0ea8bc5b3b9f66.tar.gz
Delete an XMP tag.
Diffstat (limited to 'unittest/metadata.py')
-rw-r--r--unittest/metadata.py33
1 files changed, 27 insertions, 6 deletions
diff --git a/unittest/metadata.py b/unittest/metadata.py
index 62918c5..6d106ec 100644
--- a/unittest/metadata.py
+++ b/unittest/metadata.py
@@ -82,6 +82,12 @@ class ImageMock(object):
def setXmpTagValue(self, key, value):
self.tags['xmp'][key] = value
+ def deleteXmpTag(self, key):
+ try:
+ del self.tags['xmp'][key]
+ except KeyError:
+ pass
+
class TestImageMetadata(unittest.TestCase):
@@ -555,16 +561,31 @@ class TestImageMetadata(unittest.TestCase):
self.assertEqual(self.metadata._image.tags['xmp'][key], value)
def test_delete_xmp_tag_inexistent(self):
- # TODO
- raise(NotImplementedError())
+ self.metadata.read()
+ self._set_xmp_tags()
+ key = 'Xmp.xmp.CreatorTool'
+ self.failUnlessRaises(KeyError, self.metadata._delete_xmp_tag, key)
def test_delete_xmp_tag_not_cached(self):
- # TODO
- raise(NotImplementedError())
+ self.metadata.read()
+ self._set_xmp_tags()
+ key = 'Xmp.dc.subject'
+ self.assertEqual(self.metadata._tags['xmp'], {})
+ self.assert_(self.metadata._image.tags['xmp'].has_key(key))
+ self.metadata._delete_xmp_tag(key)
+ self.assertEqual(self.metadata._tags['xmp'], {})
+ self.failIf(self.metadata._image.tags['xmp'].has_key(key))
def test_delete_xmp_tag_cached(self):
- # TODO
- raise(NotImplementedError())
+ self.metadata.read()
+ self._set_xmp_tags()
+ key = 'Xmp.dc.subject'
+ self.assert_(self.metadata._image.tags['xmp'].has_key(key))
+ tag = self.metadata._get_xmp_tag(key)
+ self.assertEqual(self.metadata._tags['xmp'][key], tag)
+ self.metadata._delete_xmp_tag(key)
+ self.assertEqual(self.metadata._tags['xmp'], {})
+ self.failIf(self.metadata._image.tags['xmp'].has_key(key))
###########################
# Test dictionary interface