aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/pyexiv2.py9
-rw-r--r--unittest/xmp.py19
2 files changed, 22 insertions, 6 deletions
diff --git a/src/pyexiv2.py b/src/pyexiv2.py
index d746a83..c679302 100644
--- a/src/pyexiv2.py
+++ b/src/pyexiv2.py
@@ -604,12 +604,11 @@ class XmpTag(MetadataTag):
elif xtype == 'Thumbnail':
# TODO
return value
- elif xtype == 'URI':
- # TODO
- return value
- elif xtype == 'URL':
- # TODO
+
+ elif xtype in ('URI', 'URL'):
+ # TODO: use urlparse?
return value
+
elif xtype == 'XPath':
# TODO
return value
diff --git a/unittest/xmp.py b/unittest/xmp.py
index 8663f64..41cf6b3 100644
--- a/unittest/xmp.py
+++ b/unittest/xmp.py
@@ -28,7 +28,6 @@ import unittest
from pyexiv2 import XmpTag, FixedOffset
import datetime
-
class TestXmpTag(unittest.TestCase):
def test_convert_to_python_boolean(self):
@@ -141,4 +140,22 @@ class TestXmpTag(unittest.TestCase):
self.assertEqual(XmpTag._convert_to_python(12, xtype), 12)
self.assertEqual(XmpTag._convert_to_python(3.14, xtype), 3.14)
+ def test_convert_to_python_uri(self):
+ xtype = 'URI'
+ # Valid values
+ self.assertEqual(XmpTag._convert_to_python('http://example.com', xtype), 'http://example.com')
+ self.assertEqual(XmpTag._convert_to_python('https://example.com', xtype), 'https://example.com')
+ self.assertEqual(XmpTag._convert_to_python('http://localhost:8000/resource', xtype),
+ 'http://localhost:8000/resource')
+ self.assertEqual(XmpTag._convert_to_python('uuid:9A3B7F52214211DAB6308A7391270C13', xtype),
+ 'uuid:9A3B7F52214211DAB6308A7391270C13')
+
+ def test_convert_to_python_url(self):
+ xtype = 'URL'
+ # Valid values
+ self.assertEqual(XmpTag._convert_to_python('http://example.com', xtype), 'http://example.com')
+ self.assertEqual(XmpTag._convert_to_python('https://example.com', xtype), 'https://example.com')
+ self.assertEqual(XmpTag._convert_to_python('http://localhost:8000/resource', xtype),
+ 'http://localhost:8000/resource')
+
# TODO: other types