diff options
author | Olivier Tilloy <olivier@tilloy.net> | 2009-02-26 09:17:29 +0100 |
---|---|---|
committer | Olivier Tilloy <olivier@tilloy.net> | 2009-02-26 09:17:29 +0100 |
commit | 08a2594633a3116cf659584026a6102437365a04 (patch) | |
tree | d9d0a8f255d4c146782df4543ab9193fad7ca7ca /unittest | |
parent | d38afdc4e6ae5209dca82d46b6d3bb6944f9e6fb (diff) | |
download | pyexiv2-08a2594633a3116cf659584026a6102437365a04.tar.gz |
EXIF unit tests.
Diffstat (limited to 'unittest')
-rw-r--r-- | unittest/exif.py | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/unittest/exif.py b/unittest/exif.py new file mode 100644 index 0000000..ae5fca0 --- /dev/null +++ b/unittest/exif.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- + +# ****************************************************************************** +# +# Copyright (C) 2009 Olivier Tilloy <olivier@tilloy.net> +# +# This file is part of the pyexiv2 distribution. +# +# pyexiv2 is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# pyexiv2 is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with pyexiv2; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA. +# +# Author: Olivier Tilloy <olivier@tilloy.net> +# +# ****************************************************************************** + +import unittest +from pyexiv2 import ExifTag, ExifValueError + + +class TestExifTag(unittest.TestCase): + + def test_convert_to_python_short(self): + xtype = 'Short' + # Valid values + self.assertEqual(ExifTag._convert_to_python('23', xtype), 23) + self.assertEqual(ExifTag._convert_to_python('+5628', xtype), 5628) + self.assertEqual(ExifTag._convert_to_python('-4', xtype), -4) + # Invalid values + self.failUnlessRaises(ExifValueError, ExifTag._convert_to_python, 'abc', xtype) + self.failUnlessRaises(ExifValueError, ExifTag._convert_to_python, '5,64', xtype) + self.failUnlessRaises(ExifValueError, ExifTag._convert_to_python, '47.0001', xtype) + self.failUnlessRaises(ExifValueError, ExifTag._convert_to_python, '1E3', xtype) + + def test_convert_to_string_short(self): + xtype = 'Short' + # Valid values + self.assertEqual(ExifTag._convert_to_string(123, xtype), '123') + self.assertEqual(ExifTag._convert_to_string(-57, xtype), '-57') + # Invalid values + self.failUnlessRaises(ExifValueError, ExifTag._convert_to_string, 'invalid', xtype) + self.failUnlessRaises(ExifValueError, ExifTag._convert_to_string, '3.14', xtype) + self.failUnlessRaises(ExifValueError, ExifTag._convert_to_string, '1E3', xtype) |