aboutsummaryrefslogtreecommitdiffstats
path: root/unittest
diff options
context:
space:
mode:
authorOlivier Tilloy <olivier@tilloy.net>2009-02-06 09:21:21 +0100
committerOlivier Tilloy <olivier@tilloy.net>2009-02-06 09:21:21 +0100
commitfb552991d0abb08dd4e3943d38e2552d02b3cafd (patch)
treef9a65ec3c61a6ae1446ebe976805ebdb1e50da66 /unittest
parent0c92278b84b6ad672e7212e460155f49c9c7437a (diff)
downloadpyexiv2-fb552991d0abb08dd4e3943d38e2552d02b3cafd.tar.gz
XMP LangAlt to string conversion + unit tests.
Diffstat (limited to 'unittest')
-rw-r--r--unittest/xmp.py26
1 files changed, 22 insertions, 4 deletions
diff --git a/unittest/xmp.py b/unittest/xmp.py
index 11fad23..9ac27f2 100644
--- a/unittest/xmp.py
+++ b/unittest/xmp.py
@@ -160,19 +160,37 @@ class TestXmpTag(unittest.TestCase):
xtype = 'Lang Alt'
# Valid values
self.assertEqual(XmpTag._convert_to_python('lang="x-default" some text', xtype),
- {'x-default': 'some text'})
+ {'x-default': u'some text'})
self.assertEqual(XmpTag._convert_to_python('lang="x-default" some text, lang="fr-FR" du texte', xtype),
- {'x-default': 'some text', 'fr-FR': 'du texte'})
+ {'x-default': u'some text', 'fr-FR': u'du texte'})
self.assertEqual(XmpTag._convert_to_python('lang="x-default" some text , lang="fr-FR" du texte ', xtype),
- {'x-default': 'some text ', 'fr-FR': ' du texte '})
+ {'x-default': u'some text ', 'fr-FR': u' du texte '})
self.assertEqual(XmpTag._convert_to_python('lang="x-default" some text, lang="fr-FR" du texte, lang="es-ES" un texto', xtype),
- {'x-default': 'some text', 'fr-FR': 'du texte', 'es-ES': 'un texto'})
+ {'x-default': u'some text', 'fr-FR': u'du texte', 'es-ES': u'un texto'})
# Invalid values
self.failUnlessRaises(XmpValueError, XmpTag._convert_to_python, 'invalid', xtype)
self.failUnlessRaises(XmpValueError, XmpTag._convert_to_python, 'lang="malformed', xtype)
self.failUnlessRaises(XmpValueError, XmpTag._convert_to_python, 'xlang="x-default" some text', xtype)
self.failUnlessRaises(XmpValueError, XmpTag._convert_to_python, 'lang="x-default" some text, xlang="fr-FR" du texte', xtype)
+ def test_convert_to_string_langalt(self):
+ xtype = 'Lang Alt'
+ # Valid values
+ self.assertEqual(XmpTag._convert_to_string({'x-default': 'some text'}, xtype),
+ 'lang="x-default" some text')
+ self.assertEqual(XmpTag._convert_to_string({'x-default': u'some text'}, xtype),
+ 'lang="x-default" some text')
+ self.assertEqual(XmpTag._convert_to_string({'x-default': 'some text', 'fr-FR': 'du texte'}, xtype),
+ 'lang="x-default" some text, lang="fr-FR" du texte')
+ self.assertEqual(XmpTag._convert_to_string({'x-default': u'some text', 'fr-FR': 'du texte'}, xtype),
+ 'lang="x-default" some text, lang="fr-FR" du texte')
+ self.assertEqual(XmpTag._convert_to_string({'x-default': u'some text', 'fr-FR': 'du texte', 'es-ES': 'un texto'}, xtype),
+ 'lang="x-default" some text, lang="es-ES" un texto, lang="fr-FR" du texte')
+ # Invalid values
+ self.failUnlessRaises(XmpValueError, XmpTag._convert_to_string, 'invalid', xtype)
+ self.failUnlessRaises(XmpValueError, XmpTag._convert_to_string, {}, xtype)
+ self.failUnlessRaises(XmpValueError, XmpTag._convert_to_string, {'x-default': 25}, xtype)
+
def test_convert_to_python_mimetype(self):
xtype = 'MIMEType'
# Valid values