diff options
Diffstat (limited to 'test/reader')
-rw-r--r-- | test/reader/image/load_nef.py | 5 | ||||
-rw-r--r-- | test/reader/image/test_image.py | 5 | ||||
-rw-r--r-- | test/reader/image/test_pillow.py | 5 | ||||
-rw-r--r-- | test/reader/image/test_raw_image.py | 9 | ||||
-rw-r--r-- | test/reader/preview/load_nef.py | 5 | ||||
-rw-r--r-- | test/reader/preview/test_pg.py | 6 | ||||
-rw-r--r-- | test/reader/preview/test_pillow.py | 11 | ||||
-rw-r--r-- | test/reader/preview/test_preview.py | 5 | ||||
-rw-r--r-- | test/reader/preview/test_rawpy.py | 5 | ||||
-rw-r--r-- | test/reader/preview/test_utils.py | 5 | ||||
-rw-r--r-- | test/reader/test_base.py | 5 | ||||
-rw-r--r-- | test/reader/test_builder.py | 5 | ||||
-rw-r--r-- | test/reader/test_chain.py | 5 | ||||
-rw-r--r-- | test/reader/test_exif.py | 52 | ||||
-rw-r--r-- | test/reader/test_path.py | 5 | ||||
-rw-r--r-- | test/reader/test_stat.py | 5 | ||||
-rw-r--r-- | test/reader/testimage_exif.jpg | bin | 0 -> 719 bytes | |||
-rw-r--r-- | test/reader/testimage_exif_corrupted.jpg | bin | 0 -> 551 bytes |
18 files changed, 60 insertions, 78 deletions
diff --git a/test/reader/image/load_nef.py b/test/reader/image/load_nef.py index 5ba0adc..02be470 100644 --- a/test/reader/image/load_nef.py +++ b/test/reader/image/load_nef.py @@ -1,9 +1,4 @@ -""" -Part of the bsie test suite. -A copy of the license is provided with the project. -Author: Matthias Baumgartner, 2022 -""" # standard imports import os diff --git a/test/reader/image/test_image.py b/test/reader/image/test_image.py index 26f6a93..ee9b8f9 100644 --- a/test/reader/image/test_image.py +++ b/test/reader/image/test_image.py @@ -1,9 +1,4 @@ -""" -Part of the bsie test suite. -A copy of the license is provided with the project. -Author: Matthias Baumgartner, 2022 -""" # standard imports import importlib import os diff --git a/test/reader/image/test_pillow.py b/test/reader/image/test_pillow.py index 8abf5c1..2cff768 100644 --- a/test/reader/image/test_pillow.py +++ b/test/reader/image/test_pillow.py @@ -1,9 +1,4 @@ -""" -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 diff --git a/test/reader/image/test_raw_image.py b/test/reader/image/test_raw_image.py index ba21b5a..3b240d0 100644 --- a/test/reader/image/test_raw_image.py +++ b/test/reader/image/test_raw_image.py @@ -1,9 +1,4 @@ -""" -Part of the bsie test suite. -A copy of the license is provided with the project. -Author: Matthias Baumgartner, 2022 -""" # standard imports import importlib import os @@ -37,10 +32,10 @@ class TestRawImage(unittest.TestCase): #self.assertEqual(img.getdata().getpixel((0, 0)), (0, 0, 0)) img.close() # raises exception when image cannot be read + self.assertRaises(errors.UnsupportedFileFormatError, rdr, + os.path.join(os.path.dirname(__file__), 'testimage.jpg')) self.assertRaises(errors.ReaderError, rdr, os.path.join(os.path.dirname(__file__), 'invalid.nef')) - self.assertRaises(errors.ReaderError, rdr, - os.path.join(os.path.dirname(__file__), 'testimage.jpg')) diff --git a/test/reader/preview/load_nef.py b/test/reader/preview/load_nef.py index 5ba0adc..02be470 100644 --- a/test/reader/preview/load_nef.py +++ b/test/reader/preview/load_nef.py @@ -1,9 +1,4 @@ -""" -Part of the bsie test suite. -A copy of the license is provided with the project. -Author: Matthias Baumgartner, 2022 -""" # standard imports import os diff --git a/test/reader/preview/test_pg.py b/test/reader/preview/test_pg.py index e492cfa..30095c5 100644 --- a/test/reader/preview/test_pg.py +++ b/test/reader/preview/test_pg.py @@ -1,9 +1,4 @@ -""" -Part of the bsie test suite. -A copy of the license is provided with the project. -Author: Matthias Baumgartner, 2022 -""" # standard imports from functools import partial import os @@ -57,6 +52,7 @@ class TestPreviewGeneratorReader(unittest.TestCase): self.assertEqual(sum(img.getdata()), 20258) # cleanup img.close() + del rdr # can define a cache dir pg_dir = tempfile.mkdtemp(prefix='bsie-test') diff --git a/test/reader/preview/test_pillow.py b/test/reader/preview/test_pillow.py index ca38d89..20f08ec 100644 --- a/test/reader/preview/test_pillow.py +++ b/test/reader/preview/test_pillow.py @@ -1,9 +1,4 @@ -""" -Part of the bsie test suite. -A copy of the license is provided with the project. -Author: Matthias Baumgartner, 2022 -""" # standard imports from functools import partial import os @@ -25,11 +20,15 @@ class TestPillowPreviewReader(unittest.TestCase): def test_call(self): rdr = PillowPreviewReader() # raises exception when image cannot be read - self.assertRaises(errors.ReaderError, rdr, + self.assertRaises(errors.UnsupportedFileFormatError, rdr, os.path.join(os.path.dirname(__file__), 'invalid.jpg')) + # raises exception when image cannot be read + self.assertRaises(errors.ReaderError, rdr, + os.path.join(os.path.dirname(__file__), 'inexistent.jpg')) # raises exception when image has invalid type self.assertRaises(errors.UnsupportedFileFormatError, rdr, os.path.join(os.path.dirname(__file__), 'invalid.foo')) + # proper file produces a generator gen = rdr(os.path.join(os.path.dirname(__file__), 'testimage.jpg')) self.assertIsInstance(gen, partial) diff --git a/test/reader/preview/test_preview.py b/test/reader/preview/test_preview.py index fde610f..e144877 100644 --- a/test/reader/preview/test_preview.py +++ b/test/reader/preview/test_preview.py @@ -1,9 +1,4 @@ -""" -Part of the bsie test suite. -A copy of the license is provided with the project. -Author: Matthias Baumgartner, 2022 -""" # standard imports from functools import partial import importlib diff --git a/test/reader/preview/test_rawpy.py b/test/reader/preview/test_rawpy.py index ed35f53..11a6f9b 100644 --- a/test/reader/preview/test_rawpy.py +++ b/test/reader/preview/test_rawpy.py @@ -1,9 +1,4 @@ -""" -Part of the bsie test suite. -A copy of the license is provided with the project. -Author: Matthias Baumgartner, 2022 -""" # standard imports from functools import partial import importlib diff --git a/test/reader/preview/test_utils.py b/test/reader/preview/test_utils.py index c10c38c..2b15bc6 100644 --- a/test/reader/preview/test_utils.py +++ b/test/reader/preview/test_utils.py @@ -1,9 +1,4 @@ -""" -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 diff --git a/test/reader/test_base.py b/test/reader/test_base.py index 41f4c29..5dd2855 100644 --- a/test/reader/test_base.py +++ b/test/reader/test_base.py @@ -1,9 +1,4 @@ -""" -Part of the bsie test suite. -A copy of the license is provided with the project. -Author: Matthias Baumgartner, 2022 -""" # standard imports import unittest diff --git a/test/reader/test_builder.py b/test/reader/test_builder.py index 92e9edc..84e8e7a 100644 --- a/test/reader/test_builder.py +++ b/test/reader/test_builder.py @@ -1,9 +1,4 @@ -""" -Part of the bsie test suite. -A copy of the license is provided with the project. -Author: Matthias Baumgartner, 2022 -""" # standard imports import unittest diff --git a/test/reader/test_chain.py b/test/reader/test_chain.py index 901faa1..665aabc 100644 --- a/test/reader/test_chain.py +++ b/test/reader/test_chain.py @@ -1,9 +1,4 @@ -""" -Part of the bsie test suite. -A copy of the license is provided with the project. -Author: Matthias Baumgartner, 2022 -""" # standard imports import logging import os diff --git a/test/reader/test_exif.py b/test/reader/test_exif.py new file mode 100644 index 0000000..de6e801 --- /dev/null +++ b/test/reader/test_exif.py @@ -0,0 +1,52 @@ + +# standard imports +import os +import unittest + +# external imports +import pyexiv2 + +# 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, + os.path.join(os.path.dirname(__file__), 'invalid.doc')) + # raises on invalid image files + self.assertRaises(errors.UnsupportedFileFormatError, rdr, + os.path.join(os.path.dirname(__file__), 'invalid.jpg')) + # raises on invalid image files + pyexiv2.set_log_level(3) # suppress log message + self.assertRaises(errors.ReaderError, rdr, + os.path.join(os.path.dirname(__file__), 'testimage_exif_corrupted.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/test_path.py b/test/reader/test_path.py index 95e447f..f2eee06 100644 --- a/test/reader/test_path.py +++ b/test/reader/test_path.py @@ -1,9 +1,4 @@ -""" -Part of the bsie test suite. -A copy of the license is provided with the project. -Author: Matthias Baumgartner, 2022 -""" # standard imports import unittest diff --git a/test/reader/test_stat.py b/test/reader/test_stat.py index fd9fdcd..f36b8b3 100644 --- a/test/reader/test_stat.py +++ b/test/reader/test_stat.py @@ -1,9 +1,4 @@ -""" -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 diff --git a/test/reader/testimage_exif.jpg b/test/reader/testimage_exif.jpg Binary files differnew file mode 100644 index 0000000..a774bc2 --- /dev/null +++ b/test/reader/testimage_exif.jpg diff --git a/test/reader/testimage_exif_corrupted.jpg b/test/reader/testimage_exif_corrupted.jpg Binary files differnew file mode 100644 index 0000000..e51a9dc --- /dev/null +++ b/test/reader/testimage_exif_corrupted.jpg |