aboutsummaryrefslogtreecommitdiffstats
path: root/unittest
diff options
context:
space:
mode:
authorOlivier Tilloy <olivier@tilloy.net>2009-04-09 09:31:36 +0200
committerOlivier Tilloy <olivier@tilloy.net>2009-04-09 09:31:36 +0200
commitc455d8b72459c7e5c106389054b61d332f19ba60 (patch)
tree6c5cd3b1642f8f9edd8adefaa88e10dc52b6ec72 /unittest
parentd33806fab7b3aebca64c1c60bc8151c334cc680b (diff)
downloadpyexiv2-c455d8b72459c7e5c106389054b61d332f19ba60.tar.gz
Custom values get/set/del for IPTC tags.
Diffstat (limited to 'unittest')
-rw-r--r--unittest/iptc.py50
1 files changed, 42 insertions, 8 deletions
diff --git a/unittest/iptc.py b/unittest/iptc.py
index 0f98b8c..38826d8 100644
--- a/unittest/iptc.py
+++ b/unittest/iptc.py
@@ -29,6 +29,20 @@ from pyexiv2 import IptcTag, IptcValueError, FixedOffset
import datetime
+class ImageMetadataMock(object):
+
+ tags = {}
+
+ def _set_iptc_tag_values(self, key, values):
+ self.tags[key] = values
+
+ def _delete_iptc_tag(self, key):
+ try:
+ del self.tags[key]
+ except KeyError:
+ pass
+
+
class TestIptcTag(unittest.TestCase):
def test_convert_to_python_short(self):
@@ -162,17 +176,37 @@ class TestIptcTag(unittest.TestCase):
self.failUnlessRaises(IptcValueError, IptcTag._convert_to_string, None, xtype)
def test_set_values_no_metadata(self):
- # TODO
- raise NotImplementedError()
+ tag = IptcTag('Iptc.Application2.City', 'City', 'City', 'Identifies ' \
+ 'city of object data origin according to guidelines ' \
+ 'established by the provider.', 'String', ['Seattle'])
+ old_values = tag.values
+ tag.values = ['Barcelona']
+ self.failIfEqual(tag.values, old_values)
def test_set_values_with_metadata(self):
- # TODO
- raise NotImplementedError()
+ tag = IptcTag('Iptc.Application2.City', 'City', 'City', 'Identifies ' \
+ 'city of object data origin according to guidelines ' \
+ 'established by the provider.', 'String', ['Seattle'])
+ tag.metadata = ImageMetadataMock()
+ old_values = tag.values
+ tag.values = ['Barcelona']
+ self.failIfEqual(tag.values, old_values)
+ self.assertEqual(tag.metadata.tags[tag.key], ['Barcelona'])
def test_del_values_no_metadata(self):
- # TODO
- raise NotImplementedError()
+ tag = IptcTag('Iptc.Application2.City', 'City', 'City', 'Identifies ' \
+ 'city of object data origin according to guidelines ' \
+ 'established by the provider.', 'String', ['Seattle'])
+ del tag.values
+ self.failIf(hasattr(tag, 'values'))
def test_del_values_with_metadata(self):
- # TODO
- raise NotImplementedError()
+ tag = IptcTag('Iptc.Application2.City', 'City', 'City', 'Identifies ' \
+ 'city of object data origin according to guidelines ' \
+ 'established by the provider.', 'String', ['Seattle'])
+ tag.metadata = ImageMetadataMock()
+ tag.metadata._set_iptc_tag_values(tag.key, tag.to_string())
+ self.assertEqual(tag.metadata.tags, {tag.key: ['Seattle']})
+ del tag.values
+ self.failIf(hasattr(tag, 'values'))
+ self.failIf(tag.metadata.tags.has_key(tag.key))