diff options
author | Olivier Tilloy <olivier@tilloy.net> | 2009-02-24 10:19:40 +0100 |
---|---|---|
committer | Olivier Tilloy <olivier@tilloy.net> | 2009-02-24 10:19:40 +0100 |
commit | 8ae2364a45e96c8afbb07ebb0499004092c1ba71 (patch) | |
tree | c8b2c2785e4202465eb76fbd246c7b5dfc4dac3f /unittest | |
parent | d28e750d9810c7ddd89335efc50e591158c26da0 (diff) | |
download | pyexiv2-8ae2364a45e96c8afbb07ebb0499004092c1ba71.tar.gz |
IPTC Time conversion.
Diffstat (limited to 'unittest')
-rw-r--r-- | unittest/iptc.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/unittest/iptc.py b/unittest/iptc.py index c339da0..43e5313 100644 --- a/unittest/iptc.py +++ b/unittest/iptc.py @@ -25,7 +25,7 @@ # ****************************************************************************** import unittest -from pyexiv2 import IptcTag, IptcValueError +from pyexiv2 import IptcTag, IptcValueError, FixedOffset import datetime @@ -65,4 +65,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_python_time(self): + xtype = 'Time' + # Valid values + self.assertEqual(IptcTag._convert_to_python('05:03:54+00:00', xtype), + datetime.time(5, 3, 54, tzinfo=FixedOffset())) + self.assertEqual(IptcTag._convert_to_python('05:03:54+06:00', xtype), + datetime.time(5, 3, 54, tzinfo=FixedOffset('+', 6, 0))) + self.assertEqual(IptcTag._convert_to_python('05:03:54-10:30', xtype), + datetime.time(5, 3, 54, tzinfo=FixedOffset('-', 10, 30))) + # Invalid values + self.failUnlessRaises(IptcValueError, IptcTag._convert_to_python, 'invalid', xtype) + self.failUnlessRaises(IptcValueError, IptcTag._convert_to_python, '23:12:42', xtype) + self.failUnlessRaises(IptcValueError, IptcTag._convert_to_python, '25:12:42+00:00', xtype) + self.failUnlessRaises(IptcValueError, IptcTag._convert_to_python, '21:77:42+00:00', xtype) + self.failUnlessRaises(IptcValueError, IptcTag._convert_to_python, '21:12:98+00:00', xtype) + self.failUnlessRaises(IptcValueError, IptcTag._convert_to_python, '081242+0000', xtype) + # TODO: other types |