aboutsummaryrefslogtreecommitdiffstats
path: root/unittest
diff options
context:
space:
mode:
Diffstat (limited to 'unittest')
-rw-r--r--unittest/xmp.py38
1 files changed, 34 insertions, 4 deletions
diff --git a/unittest/xmp.py b/unittest/xmp.py
index 2db7ca9..4b977ca 100644
--- a/unittest/xmp.py
+++ b/unittest/xmp.py
@@ -29,6 +29,20 @@ from pyexiv2 import XmpTag, XmpValueError, FixedOffset
import datetime
+class ImageMetadataMock(object):
+
+ tags = {}
+
+ def _set_xmp_tag_value(self, key, value):
+ self.tags[key] = value
+
+ def _delete_xmp_tag(self, key):
+ try:
+ del self.tags[key]
+ except KeyError:
+ pass
+
+
class TestXmpTag(unittest.TestCase):
def test_convert_to_python_bag(self):
@@ -305,12 +319,28 @@ class TestXmpTag(unittest.TestCase):
def test_set_values_no_metadata(self):
- # TODO
- raise NotImplementedError()
+ tag = XmpTag('Xmp.xmp.ModifyDate', 'ModifyDate', 'Modify Date',
+ 'The date and time the resource was last modified. Note:' \
+ ' The value of this property is not necessarily the same' \
+ "as the file's system modification date because it is " \
+ 'set before the file is saved.', 'Date',
+ '2005-09-07T15:09:51-07:00')
+ old_value = tag.value
+ tag.value = datetime.datetime(2009, 4, 22, 8, 30, 27, tzinfo=FixedOffset())
+ self.failIfEqual(tag.value, old_value)
def test_set_values_with_metadata(self):
- # TODO
- raise NotImplementedError()
+ tag = XmpTag('Xmp.xmp.ModifyDate', 'ModifyDate', 'Modify Date',
+ 'The date and time the resource was last modified. Note:' \
+ ' The value of this property is not necessarily the same' \
+ "as the file's system modification date because it is " \
+ 'set before the file is saved.', 'Date',
+ '2005-09-07T15:09:51-07:00')
+ tag.metadata = ImageMetadataMock()
+ old_value = tag.value
+ tag.value = datetime.datetime(2009, 4, 22, 8, 30, 27, tzinfo=FixedOffset())
+ self.failIfEqual(tag.value, old_value)
+ self.assertEqual(tag.metadata.tags[tag.key], '2009-04-22T08:30:27Z')
def test_del_values_no_metadata(self):
# TODO