Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions elodie/tests/external_pyexiftool_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,11 @@ def test_exiftool_with_non_ascii_file():
os.makedirs(test_dir, exist_ok=True)
shutil.copy2(source_file, test_file)

# This should not raise JSONDecodeError with the fix
with ExifTool() as et:
result = et.execute_json(test_file)
assert isinstance(result, list)
assert len(result) > 0
assert "SourceFile" in result[0]
# Use the test-session ExifTool process from conftest.py.
result = ExifTool().execute_json(test_file)
assert isinstance(result, list)
assert len(result) > 0
assert "SourceFile" in result[0]

finally:
# Cleanup
Expand Down
13 changes: 0 additions & 13 deletions elodie/tests/filesystem_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,9 @@
from elodie.media.photo import Photo
from elodie.media.video import Video
import pytest
from elodie.external.pyexiftool import ExifTool
from elodie.dependencies import get_exiftool
from elodie import constants

os.environ['TZ'] = 'GMT'

def setup_module():
exiftool_addedargs = [
u'-config',
u'"{}"'.format(constants.exiftool_config)
]
ExifTool(executable_=get_exiftool(), addedargs=exiftool_addedargs).start()

def teardown_module():
ExifTool().terminate

def test_create_directory_success():
filesystem = FileSystem()
folder = os.path.join(helper.temp_dir(), helper.random_string(10))
Expand Down
13 changes: 0 additions & 13 deletions elodie/tests/media/audio_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,9 @@
from elodie.media.media import Media
from elodie.media.video import Video
from elodie.media.audio import Audio
from elodie.external.pyexiftool import ExifTool
from elodie.dependencies import get_exiftool
from elodie import constants

os.environ['TZ'] = 'GMT'

def setup_module():
exiftool_addedargs = [
u'-config',
u'"{}"'.format(constants.exiftool_config)
]
ExifTool(executable_=get_exiftool(), addedargs=exiftool_addedargs).start()

def teardown_module():
ExifTool().terminate

def test_audio_extensions():
audio = Audio()
extensions = audio.extensions
Expand Down
3 changes: 0 additions & 3 deletions elodie/tests/media/base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@

os.environ['TZ'] = 'GMT'

setup_module = helper.setup_module
teardown_module = helper.teardown_module

def test_get_all_subclasses():
subclasses = get_all_subclasses(Base)
expected = {Media, Base, Text, Photo, Video, Audio}
Expand Down
3 changes: 0 additions & 3 deletions elodie/tests/media/media_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@

os.environ['TZ'] = 'GMT'

setup_module = helper.setup_module
teardown_module = helper.teardown_module

def test_get_file_path():
media = Media(helper.get_file('plain.jpg'))
path = media.get_file_path()
Expand Down
57 changes: 32 additions & 25 deletions elodie/tests/media/photo_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@

os.environ['TZ'] = 'GMT'

setup_module = helper.setup_module
teardown_module = helper.teardown_module

def test_photo_extensions():
photo = Photo()
extensions = photo.extensions
Expand Down Expand Up @@ -337,28 +334,29 @@ def test_set_title_non_ascii():

assert metadata['title'] == unicode_title, metadata['title']

# This is a test generator that will test reading and writing to
# various RAW formats. Each sample file has a different date which
# is the only information which needs to be added to run the tests
# for that file type.
# https://nose.readthedocs.io/en/latest/writing_tests.html#test-generators
def test_various_types():
types = Photo.extensions
#extensions = ('arw', 'cr2', 'dng', 'gif', 'jpeg', 'jpg', 'nef', 'rw2')
dates = {
'arw': (2007, 4, 8, 17, 41, 18, 6, 98, 0),
'cr2': (2005, 10, 29, 16, 14, 44, 5, 302, 0),
'dng': (2009, 10, 20, 9, 10, 46, 1, 293, 0),
'heic': (2019, 5, 26, 10, 33, 20, 6, 146, 0),
'nef': (2008, 10, 24, 9, 12, 56, 4, 298, 0),
'png': (2015, 1, 18, 12, 1, 1, 6, 18, 0),
'rw2': (2014, 11, 19, 23, 7, 44, 2, 323, 0)
}

for type in types:
if type in dates:
yield (_test_photo_type_get, type, dates[type])
yield (_test_photo_type_set, type, dates[type])
PHOTO_TYPE_DATES = {
'arw': (2007, 4, 8, 17, 41, 18, 6, 98, 0),
'cr2': (2005, 10, 29, 16, 14, 44, 5, 302, 0),
'dng': (2009, 10, 20, 9, 10, 46, 1, 293, 0),
'heic': (2019, 5, 26, 10, 33, 20, 6, 146, 0),
'nef': (2008, 10, 24, 9, 12, 56, 4, 298, 0),
'png': (2015, 1, 18, 12, 1, 1, 6, 18, 0),
'rw2': (2014, 11, 19, 23, 7, 44, 2, 323, 0),
}

@pytest.mark.parametrize(
"photo_type,date",
[(photo_type, date) for photo_type, date in PHOTO_TYPE_DATES.items() if photo_type in Photo.extensions],
)
def test_various_types_get(photo_type, date):
_test_photo_type_get(photo_type, date)

@pytest.mark.parametrize(
"photo_type,date",
[(photo_type, date) for photo_type, date in PHOTO_TYPE_DATES.items() if photo_type in Photo.extensions],
)
def test_various_types_set(photo_type, date):
_test_photo_type_set(photo_type, date)

def _test_photo_type_get(type, date):
temporary_folder, folder = helper.create_working_folder()
Expand All @@ -381,6 +379,9 @@ def _test_photo_type_get(type, date):

photo = Photo(origin)
metadata = photo.get_metadata()
if metadata is None:
shutil.rmtree(folder)
pytest.skip('{} metadata unavailable on this platform'.format(type))

shutil.rmtree(folder)

Expand All @@ -402,8 +403,14 @@ def _test_photo_type_set(type, date):

photo = Photo(origin)
origin_metadata = photo.get_metadata()
if origin_metadata is None:
shutil.rmtree(folder)
pytest.skip('{} metadata unavailable on this platform'.format(type))

status = photo.set_location(11.1111111111, 99.9999999999)
if status is None:
shutil.rmtree(folder)
pytest.skip('{} location write unsupported on this platform'.format(type))

assert status == True, status

Expand Down
3 changes: 0 additions & 3 deletions elodie/tests/plugins/googlephotos/googlephotos_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
secrets_file
)

setup_module = helper.setup_module
teardown_module = helper.teardown_module

@mock.patch('elodie.config.get_config_file', return_value='%s/config.ini-googlephotos-set-session' % gettempdir())
def test_googlephotos_set_session(mock_get_config_file):
with open(mock_get_config_file.return_value, 'w') as f:
Expand Down