aboutsummaryrefslogtreecommitdiffstats
path: root/unittest
diff options
context:
space:
mode:
authorOlivier Tilloy <olivier@tilloy.net>2009-02-06 14:37:15 +0100
committerOlivier Tilloy <olivier@tilloy.net>2009-02-06 14:37:15 +0100
commit0470d9eca9935aa8127933a1867c7bf63484b73a (patch)
treeea65cc0f5de1c3824f28212789d4ccd475c29b0a /unittest
parentfb552991d0abb08dd4e3943d38e2552d02b3cafd (diff)
downloadpyexiv2-0470d9eca9935aa8127933a1867c7bf63484b73a.tar.gz
XMP ProperName to string conversion + unit tests.
Diffstat (limited to 'unittest')
-rw-r--r--unittest/xmp.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/unittest/xmp.py b/unittest/xmp.py
index 9ac27f2..97e2eda 100644
--- a/unittest/xmp.py
+++ b/unittest/xmp.py
@@ -45,6 +45,7 @@ class TestXmpTag(unittest.TestCase):
self.assertEqual(XmpTag._convert_to_python('False', xtype), False)
# Invalid values: not converted
self.failUnlessRaises(XmpValueError, XmpTag._convert_to_python, 'invalid', xtype)
+ self.failUnlessRaises(XmpValueError, XmpTag._convert_to_python, None, xtype)
def test_convert_to_string_boolean(self):
xtype = 'Boolean'
@@ -53,6 +54,7 @@ class TestXmpTag(unittest.TestCase):
self.assertEqual(XmpTag._convert_to_string(False, xtype), 'False')
# Invalid values
self.failUnlessRaises(XmpValueError, XmpTag._convert_to_string, 'invalid', xtype)
+ self.failUnlessRaises(XmpValueError, XmpTag._convert_to_string, None, xtype)
def test_convert_to_python_choice(self):
pass
@@ -133,6 +135,7 @@ class TestXmpTag(unittest.TestCase):
'1999-10-13T05:03:27.1243-11:30')
# Invalid values
self.failUnlessRaises(XmpValueError, XmpTag._convert_to_string, 'invalid', xtype)
+ self.failUnlessRaises(XmpValueError, XmpTag._convert_to_string, None, xtype)
def test_convert_to_python_integer(self):
xtype = 'Integer'
@@ -216,6 +219,17 @@ class TestXmpTag(unittest.TestCase):
# Valid values
self.assertEqual(XmpTag._convert_to_python('Gérard', xtype), u'Gérard')
self.assertEqual(XmpTag._convert_to_python('Python Software Foundation', xtype), u'Python Software Foundation')
+ # Invalid values
+ self.failUnlessRaises(XmpValueError, XmpTag._convert_to_python, None, xtype)
+
+ def test_convert_to_string_propername(self):
+ xtype = 'ProperName'
+ # Valid values
+ self.assertEqual(XmpTag._convert_to_string('Gérard', xtype), 'Gérard')
+ self.assertEqual(XmpTag._convert_to_string(u'Gérard', xtype), 'Gérard')
+ self.assertEqual(XmpTag._convert_to_string(u'Python Software Foundation', xtype), 'Python Software Foundation')
+ # Invalid values
+ self.failUnlessRaises(XmpValueError, XmpTag._convert_to_string, None, xtype)
def test_convert_to_python_text(self):
xtype = 'Text'
@@ -223,6 +237,8 @@ class TestXmpTag(unittest.TestCase):
self.assertEqual(XmpTag._convert_to_python('Some text.', xtype), u'Some text.')
self.assertEqual(XmpTag._convert_to_python('Some text with exotic chàräctérʐ.', xtype),
u'Some text with exotic chàräctérʐ.')
+ # Invalid values
+ self.failUnlessRaises(XmpValueError, XmpTag._convert_to_python, None, xtype)
def test_convert_to_string_text(self):
xtype = 'Text'
@@ -232,6 +248,8 @@ class TestXmpTag(unittest.TestCase):
'Some text with exotic chàräctérʐ.')
self.assertEqual(XmpTag._convert_to_string('Some text with exotic chàräctérʐ.', xtype),
'Some text with exotic chàräctérʐ.')
+ # Invalid values
+ self.failUnlessRaises(XmpValueError, XmpTag._convert_to_string, None, xtype)
def test_convert_to_python_uri(self):
xtype = 'URI'