aboutsummaryrefslogtreecommitdiffstats
path: root/test/reader
diff options
context:
space:
mode:
authorMatthias Baumgartner <dev@igsor.net>2023-03-01 21:38:09 +0100
committerMatthias Baumgartner <dev@igsor.net>2023-03-01 21:38:09 +0100
commitec9105b690974b0246e36769506e735c4edf069a (patch)
treec79a3a4489baae55fb74d84714ed728b79e50784 /test/reader
parent464cc6cb54f55f6255bf0a485533c181d6018303 (diff)
downloadbsie-ec9105b690974b0246e36769506e735c4edf069a.tar.gz
bsie-ec9105b690974b0246e36769506e735c4edf069a.tar.bz2
bsie-ec9105b690974b0246e36769506e735c4edf069a.zip
Exif data reader and extractor
Diffstat (limited to 'test/reader')
-rw-r--r--test/reader/test_exif.py48
-rw-r--r--test/reader/testimage_exif.jpgbin0 -> 719 bytes
2 files changed, 48 insertions, 0 deletions
diff --git a/test/reader/test_exif.py b/test/reader/test_exif.py
new file mode 100644
index 0000000..f1330da
--- /dev/null
+++ b/test/reader/test_exif.py
@@ -0,0 +1,48 @@
+"""
+
+Part of the bsie test suite.
+A copy of the license is provided with the project.
+Author: Matthias Baumgartner, 2022
+"""
+# standard imports
+import os
+import unittest
+
+# bsie imports
+from bsie.utils import errors
+
+# objects to test
+from bsie.reader.exif import Exif
+
+
+## code ##
+
+class TestExif(unittest.TestCase):
+ def test_call(self):
+ rdr = Exif()
+ # discards non-image files
+ self.assertRaises(errors.UnsupportedFileFormatError, rdr, 'invalid.doc')
+ # raises on invalid image files
+ self.assertRaises(errors.ReaderError, rdr, 'invalid.jpg')
+ # returns dict with exif info
+ self.assertDictEqual(rdr(os.path.join(os.path.dirname(__file__), 'testimage_exif.jpg')), {
+ 'Exif.Image.Artist': 'nobody',
+ 'Exif.Image.ExifTag': '110',
+ 'Exif.Image.ResolutionUnit': '2',
+ 'Exif.Image.XResolution': '300/1',
+ 'Exif.Image.YCbCrPositioning': '1',
+ 'Exif.Image.YResolution': '300/1',
+ 'Exif.Photo.ColorSpace': '65535',
+ 'Exif.Photo.ComponentsConfiguration': '1 2 3 0',
+ 'Exif.Photo.ExifVersion': '48 50 51 50',
+ 'Exif.Photo.FlashpixVersion': '48 49 48 48',
+ 'Exif.Photo.ISOSpeedRatings': '200',
+ })
+
+
+## main ##
+
+if __name__ == '__main__':
+ unittest.main()
+
+## EOF ##
diff --git a/test/reader/testimage_exif.jpg b/test/reader/testimage_exif.jpg
new file mode 100644
index 0000000..a774bc2
--- /dev/null
+++ b/test/reader/testimage_exif.jpg
Binary files differ