aboutsummaryrefslogtreecommitdiffstats
path: root/unittest
diff options
context:
space:
mode:
authorOlivier Tilloy <olivier@tilloy.net>2009-02-25 09:36:39 +0100
committerOlivier Tilloy <olivier@tilloy.net>2009-02-25 09:36:39 +0100
commit87e717129934903f87048db77cab9fd0b440757c (patch)
treeb68d1620fb1deaa76918a3b0b44aacaa00545c17 /unittest
parent943641e68b1b0d50262c8008fe6a3e61151f48a2 (diff)
downloadpyexiv2-87e717129934903f87048db77cab9fd0b440757c.tar.gz
IPTC Date to string conversion.
Diffstat (limited to 'unittest')
-rw-r--r--unittest/iptc.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/unittest/iptc.py b/unittest/iptc.py
index 2d747d1..dd633d7 100644
--- a/unittest/iptc.py
+++ b/unittest/iptc.py
@@ -86,6 +86,21 @@ class TestIptcTag(unittest.TestCase):
self.failUnlessRaises(IptcValueError, IptcTag._convert_to_python, '2009-10-32', xtype)
self.failUnlessRaises(IptcValueError, IptcTag._convert_to_python, '2009-02-24T22:12:54', xtype)
+ def test_convert_to_string_date(self):
+ xtype = 'Date'
+ # Valid values
+ self.assertEqual(IptcTag._convert_to_string(datetime.date(2009, 2, 4), xtype),
+ '20090204')
+ self.assertEqual(IptcTag._convert_to_string(datetime.datetime(1999, 10, 13), xtype),
+ '19991013')
+ self.assertEqual(IptcTag._convert_to_string(datetime.datetime(2009, 2, 4), xtype),
+ '20090204')
+ self.assertEqual(IptcTag._convert_to_string(datetime.datetime(2009, 2, 4, 10, 52, 37), xtype),
+ '20090204')
+ # Invalid values
+ self.failUnlessRaises(IptcValueError, IptcTag._convert_to_string, 'invalid', xtype)
+ self.failUnlessRaises(IptcValueError, IptcTag._convert_to_string, None, xtype)
+
def test_convert_to_python_time(self):
xtype = 'Time'
# Valid values