aboutsummaryrefslogtreecommitdiffstats
path: root/unittest
diff options
context:
space:
mode:
authorOlivier Tilloy <olivier@tilloy.net>2009-02-24 09:49:17 +0100
committerOlivier Tilloy <olivier@tilloy.net>2009-02-24 09:49:17 +0100
commitd28e750d9810c7ddd89335efc50e591158c26da0 (patch)
tree17c468b7d80b1fc79824134d992d570631140f7f /unittest
parent6cb7e04dbde3309e575223ec5dc09cc85e61ff11 (diff)
downloadpyexiv2-d28e750d9810c7ddd89335efc50e591158c26da0.tar.gz
IPTC Date conversion.
Diffstat (limited to 'unittest')
-rw-r--r--unittest/iptc.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/unittest/iptc.py b/unittest/iptc.py
index 035b435..c339da0 100644
--- a/unittest/iptc.py
+++ b/unittest/iptc.py
@@ -26,6 +26,7 @@
import unittest
from pyexiv2 import IptcTag, IptcValueError
+import datetime
class TestIptcTag(unittest.TestCase):
@@ -51,4 +52,17 @@ class TestIptcTag(unittest.TestCase):
# Invalid values
self.failUnlessRaises(IptcValueError, IptcTag._convert_to_python, None, xtype)
+ def test_convert_to_python_date(self):
+ xtype = 'Date'
+ # Valid values
+ self.assertEqual(IptcTag._convert_to_python('1999-10-13', xtype),
+ datetime.date(1999, 10, 13))
+ # Invalid values
+ self.failUnlessRaises(IptcValueError, IptcTag._convert_to_python, 'invalid', xtype)
+ self.failUnlessRaises(IptcValueError, IptcTag._convert_to_python, '11/10/1983', xtype)
+ self.failUnlessRaises(IptcValueError, IptcTag._convert_to_python, '-1000', xtype)
+ self.failUnlessRaises(IptcValueError, IptcTag._convert_to_python, '2009-02', xtype)
+ self.failUnlessRaises(IptcValueError, IptcTag._convert_to_python, '2009-10-32', xtype)
+ self.failUnlessRaises(IptcValueError, IptcTag._convert_to_python, '2009-02-24T22:12:54', xtype)
+
# TODO: other types