From d28e750d9810c7ddd89335efc50e591158c26da0 Mon Sep 17 00:00:00 2001 From: Olivier Tilloy Date: Tue, 24 Feb 2009 09:49:17 +0100 Subject: IPTC Date conversion. --- unittest/iptc.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'unittest/iptc.py') 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 -- cgit