From 1c0372141f57355564aab38b353bcdc68a55301c Mon Sep 17 00:00:00 2001 From: Jaisen Mathai Date: Wed, 23 Mar 2016 11:29:02 -0700 Subject: [PATCH] gh-93 Add tests for RW2 files gh-94 Skip test for writing to RW2 files because they are not supported --- elodie/tests/media/photo_test.py | 55 ++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/elodie/tests/media/photo_test.py b/elodie/tests/media/photo_test.py index 221364a..8425fe7 100644 --- a/elodie/tests/media/photo_test.py +++ b/elodie/tests/media/photo_test.py @@ -342,3 +342,58 @@ def test_set_metadata_on_dng(): assert metadata['date_taken'] == helper.time_convert((2009, 10, 20, 9, 10, 46, 1, 293, 0)), metadata['date_taken'] assert helper.isclose(metadata['latitude'], 11.1111111111), metadata['latitude'] assert helper.isclose(metadata['longitude'], 99.9999999999), metadata['longitude'] + +def test_get_metadata_from_rw2(): + temporary_folder, folder = helper.create_working_folder() + + photo_file = helper.get_file('photo.rw2') + origin = '%s/photo.rw2' % folder + + if not photo_file: + photo_file = helper.download_file('photo.rw2', folder) + if not photo_file or not os.path.isfile(photo_file): + raise SkipTest('rw2 file not downlaoded') + + # downloading for each test is costly so we save it in the working directory + file_path_save_as = helper.get_file_path('photo.rw2') + if os.path.isfile(photo_file): + shutil.copyfile(photo_file, file_path_save_as) + + shutil.copyfile(photo_file, origin) + + photo = Photo(origin) + metadata = photo.get_metadata() + + shutil.rmtree(folder) + + assert metadata['date_taken'] == helper.time_convert((2014, 11, 19, 23, 7, 44, 2, 323, 0)), metadata['date_taken'] + +def test_set_metadata_on_rw2(): + raise SkipTest('gh-94 Writing to RW2 images is not supported') + temporary_folder, folder = helper.create_working_folder() + + photo_file = helper.get_file('photo.rw2') + origin = '%s/photo.rw2' % folder + + if not photo_file: + photo_file = helper.download_file('photo.rw2', folder) + if not photo_file or not os.path.isfile(photo_file): + raise SkipTest('rw2 file not downlaoded') + + shutil.copyfile(photo_file, origin) + + photo = Photo(origin) + origin_metadata = photo.get_metadata() + + status = photo.set_location(11.1111111111, 99.9999999999) + + assert status == True, status + + photo_new = Photo(origin) + metadata = photo_new.get_metadata() + + shutil.rmtree(folder) + + assert metadata['date_taken'] == helper.time_convert((2014, 11, 19, 23, 7, 44, 2, 323, 0)), metadata['date_taken'] + assert helper.isclose(metadata['latitude'], 11.1111111111), metadata['latitude'] + assert helper.isclose(metadata['longitude'], 99.9999999999), metadata['longitude']