aboutsummaryrefslogtreecommitdiffstats
path: root/unittest
diff options
context:
space:
mode:
authorOlivier Tilloy <olivier@tilloy.net>2009-02-25 09:59:32 +0100
committerOlivier Tilloy <olivier@tilloy.net>2009-02-25 09:59:32 +0100
commit07b77b0d18d9c7c90e89804791d5d78dc13017e6 (patch)
treef94eed42f7e25805d1bc151f8ac586ea61d821fa /unittest
parent87e717129934903f87048db77cab9fd0b440757c (diff)
downloadpyexiv2-07b77b0d18d9c7c90e89804791d5d78dc13017e6.tar.gz
IPTC Time to string conversion.
Diffstat (limited to 'unittest')
-rw-r--r--unittest/iptc.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/unittest/iptc.py b/unittest/iptc.py
index dd633d7..70eb977 100644
--- a/unittest/iptc.py
+++ b/unittest/iptc.py
@@ -118,6 +118,32 @@ class TestIptcTag(unittest.TestCase):
self.failUnlessRaises(IptcValueError, IptcTag._convert_to_python, '21:12:98+00:00', xtype)
self.failUnlessRaises(IptcValueError, IptcTag._convert_to_python, '081242+0000', xtype)
+ def test_convert_to_string_time(self):
+ xtype = 'Time'
+ # Valid values
+ self.assertEqual(IptcTag._convert_to_string(datetime.time(10, 52, 4), xtype),
+ '105204+0000')
+ self.assertEqual(IptcTag._convert_to_string(datetime.time(10, 52, 4, 574), xtype),
+ '105204+0000')
+ self.assertEqual(IptcTag._convert_to_string(datetime.time(10, 52, 4, tzinfo=FixedOffset()), xtype),
+ '105204+0000')
+ self.assertEqual(IptcTag._convert_to_string(datetime.time(10, 52, 4, tzinfo=FixedOffset('+', 5, 30)), xtype),
+ '105204+0530')
+ self.assertEqual(IptcTag._convert_to_string(datetime.time(10, 52, 4, tzinfo=FixedOffset('-', 4, 0)), xtype),
+ '105204-0400')
+ self.assertEqual(IptcTag._convert_to_string(datetime.datetime(2007, 2, 7, 10, 52, 4), xtype),
+ '105204+0000')
+ self.assertEqual(IptcTag._convert_to_string(datetime.datetime(2007, 2, 7, 10, 52, 4, 478), xtype),
+ '105204+0000')
+ self.assertEqual(IptcTag._convert_to_string(datetime.datetime(2007, 2, 7, 10, 52, 4, tzinfo=FixedOffset()), xtype),
+ '105204+0000')
+ self.assertEqual(IptcTag._convert_to_string(datetime.datetime(2007, 2, 7, 10, 52, 4, tzinfo=FixedOffset('+', 5, 30)), xtype),
+ '105204+0530')
+ self.assertEqual(IptcTag._convert_to_string(datetime.datetime(2007, 2, 7, 10, 52, 4, tzinfo=FixedOffset('-', 4, 0)), xtype),
+ '105204-0400')
+ # Invalid values
+ self.failUnlessRaises(IptcValueError, IptcTag._convert_to_python, 'invalid', xtype)
+
def test_convert_to_python_undefined(self):
xtype = 'Undefined'
# Valid values