aboutsummaryrefslogtreecommitdiffstats
path: root/unittest
diff options
context:
space:
mode:
authorOlivier Tilloy <olivier@tilloy.net>2009-04-08 09:29:34 +0200
committerOlivier Tilloy <olivier@tilloy.net>2009-04-08 09:29:34 +0200
commitf47b027237b1081818615d18ee0475ca8a4663d3 (patch)
tree342aaccf98c99e2765019a67d0839554ee898cb3 /unittest
parent958ad5168aaf8b8b01c1bd664eea591818e32d04 (diff)
downloadpyexiv2-f47b027237b1081818615d18ee0475ca8a4663d3.tar.gz
Delete an IPTC tag.
Diffstat (limited to 'unittest')
-rw-r--r--unittest/metadata.py33
1 files changed, 27 insertions, 6 deletions
diff --git a/unittest/metadata.py b/unittest/metadata.py
index 0fc3b4c..ade5599 100644
--- a/unittest/metadata.py
+++ b/unittest/metadata.py
@@ -67,6 +67,12 @@ class ImageMock(object):
def setIptcTagValues(self, key, values):
self.tags['iptc'][key] = values
+ def deleteIptcTag(self, key):
+ try:
+ del self.tags['iptc'][key]
+ except KeyError:
+ pass
+
def xmpKeys(self):
return self.tags['xmp'].keys()
@@ -402,16 +408,31 @@ class TestImageMetadata(unittest.TestCase):
self.assertEqual(self.metadata._image.tags['iptc'][key], values)
def test_delete_iptc_tag_inexistent(self):
- # TODO
- raise(NotImplementedError())
+ self.metadata.read()
+ self._set_iptc_tags()
+ key = 'Iptc.Application2.LocationCode'
+ self.failUnlessRaises(KeyError, self.metadata._delete_iptc_tag, key)
def test_delete_iptc_tag_not_cached(self):
- # TODO
- raise(NotImplementedError())
+ self.metadata.read()
+ self._set_iptc_tags()
+ key = 'Iptc.Application2.Caption'
+ self.assertEqual(self.metadata._tags['iptc'], {})
+ self.assert_(self.metadata._image.tags['iptc'].has_key(key))
+ self.metadata._delete_iptc_tag(key)
+ self.assertEqual(self.metadata._tags['iptc'], {})
+ self.failIf(self.metadata._image.tags['iptc'].has_key(key))
def test_delete_iptc_tag_cached(self):
- # TODO
- raise(NotImplementedError())
+ self.metadata.read()
+ self._set_iptc_tags()
+ key = 'Iptc.Application2.Caption'
+ self.assert_(self.metadata._image.tags['iptc'].has_key(key))
+ tag = self.metadata._get_iptc_tag(key)
+ self.assertEqual(self.metadata._tags['iptc'][key], tag)
+ self.metadata._delete_iptc_tag(key)
+ self.assertEqual(self.metadata._tags['iptc'], {})
+ self.failIf(self.metadata._image.tags['iptc'].has_key(key))
##########################
# Test XMP-related methods