aboutsummaryrefslogtreecommitdiffstats
path: root/unittest
diff options
context:
space:
mode:
authorOlivier Tilloy <olivier@tilloy.net>2008-02-06 23:21:00 +0100
committerOlivier Tilloy <olivier@tilloy.net>2008-02-06 23:21:00 +0100
commit6985a2ede4715d2fe2366b7a1852970510312ee7 (patch)
tree6d0d8faf44e760afa52946bac6711a4db9cf6b3d /unittest
parent5d55e66e5ac0b1f1c476d42a08462c538a89b53f (diff)
downloadpyexiv2-6985a2ede4715d2fe2366b7a1852970510312ee7.tar.gz
Added a unit test for bug #183332 (currently failing as the bug is not fixed yet).
Diffstat (limited to 'unittest')
-rw-r--r--unittest/Bug183332_TestCase.py63
-rwxr-xr-xunittest/TestsRunner.py2
2 files changed, 65 insertions, 0 deletions
diff --git a/unittest/Bug183332_TestCase.py b/unittest/Bug183332_TestCase.py
new file mode 100644
index 0000000..7cedcb4
--- /dev/null
+++ b/unittest/Bug183332_TestCase.py
@@ -0,0 +1,63 @@
+#!/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: Bug183332_TestCase.py
+# Author(s): Olivier Tilloy <olivier@tilloy.net>
+#
+# ******************************************************************************
+
+import unittest
+import testutils
+import os.path
+import pyexiv2
+
+class Bug183332_TestCase(unittest.TestCase):
+
+ """
+ Test case for bug #183332.
+
+ Summary: Cached metadata is not converted to its correct type.
+ Description: When setting the value of a tag, its value is automatically
+ converted to the correct type, but the value held in the internal cache is
+ not.
+ """
+
+ def testSetTagValue(self):
+ """
+ Test the value type of the internally cached metadata after setting an
+ IPTC tag.
+ """
+ # Check that the reference file is not corrupted
+ filename = os.path.join('data', 'smiley1.jpg')
+ md5sum = 'c066958457c685853293058f9bf129c1'
+ self.assert_(testutils.CheckFileSum(filename, md5sum))
+
+ image = pyexiv2.Image(filename)
+ image.readMetadata()
+ key = 'Iptc.Application2.Keywords'
+ values = (5, 6)
+ # IPTC keywords are strings, voluntarily pass integers as arguments
+ image[key] = values
+ self.assertEqual(image[key], tuple([str(v) for v in values]))
+
diff --git a/unittest/TestsRunner.py b/unittest/TestsRunner.py
index 0c99b1a..ecde62a 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 Bug183332_TestCase import Bug183332_TestCase
from Bug183618_TestCase import Bug183618_TestCase
if __name__ == '__main__':
@@ -45,6 +46,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(Bug183332_TestCase))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(Bug183618_TestCase))
# Run the test suite
unittest.TextTestRunner(verbosity=2).run(suite)