aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/metadata.py9
-rw-r--r--test/xmp.py20
2 files changed, 27 insertions, 2 deletions
diff --git a/test/metadata.py b/test/metadata.py
index 177ec9d..a00d9fa 100644
--- a/test/metadata.py
+++ b/test/metadata.py
@@ -2,7 +2,7 @@
# ******************************************************************************
#
-# Copyright (C) 2009-2010 Olivier Tilloy <olivier@tilloy.net>
+# Copyright (C) 2009-2011 Olivier Tilloy <olivier@tilloy.net>
#
# This file is part of the pyexiv2 distribution.
#
@@ -564,6 +564,13 @@ class TestImageMetadata(unittest.TestCase):
for key in keys:
self.metadata[key] = self.metadata[key]
+ def test_nonexistent_tag_family(self):
+ self.metadata.read()
+ key = 'Bleh.Image.DateTime'
+ self.failUnlessRaises(KeyError, self.metadata.__getitem__, key)
+ self.failUnlessRaises(KeyError, self.metadata.__setitem__, key, datetime.date.today())
+ self.failUnlessRaises(KeyError, self.metadata.__delitem__, key)
+
##########################
# Test the image comment #
##########################
diff --git a/test/xmp.py b/test/xmp.py
index 7e7522e..6183277 100644
--- a/test/xmp.py
+++ b/test/xmp.py
@@ -2,7 +2,7 @@
# ******************************************************************************
#
-# Copyright (C) 2009-2010 Olivier Tilloy <olivier@tilloy.net>
+# Copyright (C) 2009-2011 Olivier Tilloy <olivier@tilloy.net>
#
# This file is part of the pyexiv2 distribution.
#
@@ -364,6 +364,24 @@ class TestXmpTag(unittest.TestCase):
self.failUnlessEqual(tag.type, 'Lang Alt')
self.failUnlessRaises(ValueError, tag._set_value, {})
+ def test_set_value_incorrect_type(self):
+ # Expecting a list of values
+ tag = XmpTag('Xmp.dc.publisher')
+ self.failUnlessEqual(tag.type, 'bag ProperName')
+ self.failUnlessRaises(TypeError, tag._set_value, None)
+ self.failUnlessRaises(TypeError, tag._set_value, 'bleh')
+ # Expecting a dictionary mapping language codes to values
+ tag = XmpTag('Xmp.dc.description')
+ self.failUnlessEqual(tag.type, 'Lang Alt')
+ self.failUnlessRaises(TypeError, tag._set_value, None)
+ self.failUnlessRaises(TypeError, tag._set_value, ['bleh'])
+
+ def test_set_value_basestring_for_langalt(self):
+ tag = XmpTag('Xmp.dc.description')
+ self.failUnlessEqual(tag.type, 'Lang Alt')
+ tag.value = 'bleh'
+ self.failUnlessEqual(tag.value, {'x-default': 'bleh'})
+
class TestXmpNamespaces(unittest.TestCase):