aboutsummaryrefslogtreecommitdiffstats
path: root/unittest/xmp.py
diff options
context:
space:
mode:
authorOlivier Tilloy <olivier@tilloy.net>2009-02-06 19:11:41 +0100
committerOlivier Tilloy <olivier@tilloy.net>2009-02-06 19:11:41 +0100
commit6681e06718c9d124fdedcd9653dec7da2c7c49ed (patch)
treebd2735128e4c1efdd160a98f5ba0eb015152de52 /unittest/xmp.py
parent1e3ce8ad1f2bfb030665523001aa4bec718a1b6d (diff)
downloadpyexiv2-6681e06718c9d124fdedcd9653dec7da2c7c49ed.tar.gz
XMP bag to string conversion + unit tests.
Diffstat (limited to 'unittest/xmp.py')
-rw-r--r--unittest/xmp.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/unittest/xmp.py b/unittest/xmp.py
index 1ee2c99..e770b06 100644
--- a/unittest/xmp.py
+++ b/unittest/xmp.py
@@ -33,11 +33,25 @@ class TestXmpTag(unittest.TestCase):
def test_convert_to_python_bag(self):
xtype = 'bag Text'
# Valid values
- self.assertEqual(XmpTag._convert_to_python('', xtype), [u''])
+ self.assertEqual(XmpTag._convert_to_python('', xtype), [])
self.assertEqual(XmpTag._convert_to_python('One value only', xtype), [u'One value only'])
self.assertEqual(XmpTag._convert_to_python('Some, text, keyword, this is a test', xtype),
[u'Some', u'text', u'keyword', u'this is a test'])
+ def test_convert_to_string_bag(self):
+ xtype = 'bag Text'
+ # Valid values
+ self.assertEqual(XmpTag._convert_to_string([], xtype), '')
+ self.assertEqual(XmpTag._convert_to_string(['One value only'], xtype), 'One value only')
+ self.assertEqual(XmpTag._convert_to_string([u'One value only'], xtype), 'One value only')
+ self.assertEqual(XmpTag._convert_to_string([u'Some', u'text', u'keyword', u'this is a test'], xtype),
+ 'Some, text, keyword, this is a test')
+ self.assertEqual(XmpTag._convert_to_string(['Some ', ' text '], xtype),
+ 'Some , text ')
+ # Invalid values
+ self.failUnlessRaises(XmpValueError, XmpTag._convert_to_string, 'invalid', xtype)
+ self.failUnlessRaises(XmpValueError, XmpTag._convert_to_string, [1, 2, 3], xtype)
+
def test_convert_to_python_boolean(self):
xtype = 'Boolean'
# Valid values