aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Tilloy <olivier@tilloy.net>2008-02-01 00:01:47 +0100
committerOlivier Tilloy <olivier@tilloy.net>2008-02-01 00:01:47 +0100
commit19860755ec63b04a622a200988f6d78c10d0bfeb (patch)
tree6fb7d549907083d5bb4d8dbd78b31a5ef5ca8a50
parentf466a882835271cc98d59f4e77b105282bcaa76e (diff)
downloadpyexiv2-19860755ec63b04a622a200988f6d78c10d0bfeb.tar.gz
Added a unit test for bug #183618.
-rw-r--r--unittest/Bug183618_TestCase.py85
-rwxr-xr-xunittest/TestsRunner.py2
-rw-r--r--unittest/data/bug183618.jpgbin0 -> 3911 bytes
3 files changed, 87 insertions, 0 deletions
diff --git a/unittest/Bug183618_TestCase.py b/unittest/Bug183618_TestCase.py
new file mode 100644
index 0000000..e9da010
--- /dev/null
+++ b/unittest/Bug183618_TestCase.py
@@ -0,0 +1,85 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# ******************************************************************************
+#
+# Copyright (C) 2006-2007 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.
+#
+#
+# File: Bug183618_TestCase.py
+# Author(s): Olivier Tilloy <olivier@tilloy.net>
+#
+# ******************************************************************************
+
+import unittest
+import testutils
+import os.path
+import pyexiv2
+
+class Bug183618_TestCase(unittest.TestCase):
+
+ """
+ Test case for bug #183618.
+
+ Summary: Exif.GPSInfo.{GPSLongitude,Latitude} are not decoded.
+ Description: The GPS latitude and longitude data is not correctly decoded
+ because multiple value fields for EXIF tags are not correctly dealt with:
+ only the first value is extracted and returned.
+ Fix: fixed with revision 79, behaviour changed with revision 82.
+ """
+
+ def checkTypeAndValue(self, tag, etype, evalue):
+ """
+ Check the type and the value of a metadata tag against expected values.
+
+ Keyword arguments:
+ tag -- the full name of the tag (eg. 'Exif.Image.DateTime')
+ etype -- the expected type of the tag value
+ evalue -- the expected value of the tag
+ """
+ self.assertEqual(tag.__class__, etype)
+ self.assertEqual(tag, evalue)
+
+ def testReadGPSMetadata(self):
+ """
+ Test the extraction of the GPS metadata from a file.
+ """
+ # Check that the reference file is not corrupted
+ filename = os.path.join('data', 'bug183618.jpg')
+ md5sum = 'ccddff432b0a2dc8f544f0f380e1fa6d'
+ self.assert_(testutils.CheckFileSum(filename, md5sum))
+
+ # Read the image metadata
+ image = pyexiv2.Image(filename)
+ image.readMetadata()
+
+ # Exhaustive tests on the values of EXIF GPS metadata
+ gpsTags = [('Exif.Image.GPSTag', long, 1313L),
+ ('Exif.GPSInfo.GPSVersionID', str, '2 0 0 0 '),
+ ('Exif.GPSInfo.GPSLatitudeRef', str, 'N'),
+ ('Exif.GPSInfo.GPSLatitude', tuple, (pyexiv2.Rational(47, 1), pyexiv2.Rational(3817443, 1000000), pyexiv2.Rational(0, 1))),
+ ('Exif.GPSInfo.GPSLongitudeRef', str, 'E'),
+ ('Exif.GPSInfo.GPSLongitude', tuple, (pyexiv2.Rational(8, 1), pyexiv2.Rational(41359940, 1000000), pyexiv2.Rational(0, 1))),
+ ('Exif.GPSInfo.GPSAltitudeRef', str, '0 '),
+ ('Exif.GPSInfo.GPSAltitude', pyexiv2.Rational, pyexiv2.Rational(1908629, 1250)),
+ ('Exif.GPSInfo.GPSMapDatum', str, 'WGS-84')]
+ self.assertEqual([tag for tag in image.exifKeys() if tag.find('GPS') != -1], [tag[0] for tag in gpsTags])
+ for tag in gpsTags:
+ self.checkTypeAndValue(image[tag[0]], tag[1], tag[2])
+
diff --git a/unittest/TestsRunner.py b/unittest/TestsRunner.py
index 122b82d..0c99b1a 100755
--- a/unittest/TestsRunner.py
+++ b/unittest/TestsRunner.py
@@ -35,6 +35,7 @@ from ReadMetadataTestCase import ReadMetadataTestCase
from Bug146313_TestCase import Bug146313_TestCase
from Bug173387_TestCase import Bug173387_TestCase
from Bug175070_TestCase import Bug175070_TestCase
+from Bug183618_TestCase import Bug183618_TestCase
if __name__ == '__main__':
# Instantiate a test suite containing all the test cases
@@ -44,6 +45,7 @@ if __name__ == '__main__':
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(Bug146313_TestCase))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(Bug173387_TestCase))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(Bug175070_TestCase))
+ suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(Bug183618_TestCase))
# Run the test suite
unittest.TextTestRunner(verbosity=2).run(suite)
diff --git a/unittest/data/bug183618.jpg b/unittest/data/bug183618.jpg
new file mode 100644
index 0000000..75de1ee
--- /dev/null
+++ b/unittest/data/bug183618.jpg
Binary files differ