diff --git a/.gitignore b/.gitignore index e2dab5d..192a5e2 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ dist/** docs/_build build/** -**/*.nef +**/*.arw **/*.dng +**/*.nef **/*.rw2 diff --git a/elodie/media/photo.py b/elodie/media/photo.py index dd4a7f4..5086a47 100644 --- a/elodie/media/photo.py +++ b/elodie/media/photo.py @@ -27,7 +27,7 @@ class Photo(Media): __name__ = 'Photo' #: Valid extensions for photo files. - extensions = ('dng', 'gif', 'jpeg', 'jpg', 'nef', 'rw2') + extensions = ('arw', 'dng', 'gif', 'jpeg', 'jpg', 'nef', 'rw2') def __init__(self, source=None): super(Photo, self).__init__(source) diff --git a/elodie/tests/media/photo_test.py b/elodie/tests/media/photo_test.py index 8425fe7..c100b1d 100644 --- a/elodie/tests/media/photo_test.py +++ b/elodie/tests/media/photo_test.py @@ -397,3 +397,57 @@ def test_set_metadata_on_rw2(): 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'] + +def test_get_metadata_from_arw(): + temporary_folder, folder = helper.create_working_folder() + + photo_file = helper.get_file('photo.arw') + origin = '%s/photo.arw' % folder + + if not photo_file: + photo_file = helper.download_file('photo.arw', folder) + if not photo_file or not os.path.isfile(photo_file): + raise SkipTest('arw 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.arw') + 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((2007, 4, 8, 17, 41, 18, 6, 98, 0)), metadata['date_taken'] + +def test_set_metadata_on_arw(): + temporary_folder, folder = helper.create_working_folder() + + photo_file = helper.get_file('photo.arw') + origin = '%s/photo.arw' % folder + + if not photo_file: + photo_file = helper.download_file('photo.arw', folder) + if not photo_file or not os.path.isfile(photo_file): + raise SkipTest('arw 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((2007, 4, 8, 17, 41, 18, 6, 98, 0)), metadata['date_taken'] + assert helper.isclose(metadata['latitude'], 11.1111111111), metadata['latitude'] + assert helper.isclose(metadata['longitude'], 99.9999999999), metadata['longitude']