Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test to verify that full_path in config.ini works properly #334 #335

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
60 changes: 60 additions & 0 deletions elodie/tests/elodie_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,34 @@ def test_import_file_send_to_trash_true():

assert dest_path1 is not None

@mock.patch('elodie.config.config_file', '%s/config.ini-import-with-full-path' % gettempdir())
def test_import_with_full_path():
with open('%s/config.ini-import-with-full-path' % gettempdir(), 'w') as f:
f.write("""
[Directory]
location=%city
date=%Y-%m
full_path=%date/%location
""")
if hasattr(load_config, 'config'):
del load_config.config

temporary_folder, folder = helper.create_working_folder()
temporary_folder_destination, folder_destination = helper.create_working_folder()

origin = '%s/plain.jpg' % folder
shutil.copyfile(helper.get_file('plain.jpg'), origin)

dest_path = elodie.import_file(origin, folder_destination, False, True, False)

shutil.rmtree(folder)
shutil.rmtree(folder_destination)

if hasattr(load_config, 'config'):
del load_config.config

assert '2015-12/Unknown Location/2015-12-05_00-59-26-plain.jpg' in dest_path, dest_path

def test_import_destination_in_source():
temporary_folder, folder = helper.create_working_folder()
folder_destination = '{}/destination'.format(folder)
Expand Down Expand Up @@ -607,6 +635,38 @@ def test_verify_error():
assert origin in result.output, result.output
assert 'Error 1' in result.output, result.output

@mock.patch('elodie.config.config_file', '%s/config.ini-cli-import-with-full-path' % gettempdir())
def test_cli_import_with_full_path():
with open('%s/config.ini-cli-import-with-full-path' % gettempdir(), 'w') as f:
f.write("""
[Directory]
location=%city
date=%Y-%m
full_path=%date/%location
""")
if hasattr(load_config, 'config'):
del load_config.config


temporary_folder, folder = helper.create_working_folder()
temporary_folder_destination, folder_destination = helper.create_working_folder()

origin = '%s/plain.jpg' % folder
shutil.copyfile(helper.get_file('plain.jpg'), origin)

runner = CliRunner()
# import
result = runner.invoke(elodie._import, ['--destination', folder_destination, origin])


shutil.rmtree(folder)
shutil.rmtree(folder_destination)

if hasattr(load_config, 'config'):
del load_config.config

assert '2015-12/Unknown Location/2015-12-05_00-59-26-plain.jpg' in result.output, result.output

@mock.patch('elodie.config.config_file', '%s/config.ini-cli-batch-plugin-googlephotos' % gettempdir())
def test_cli_batch_plugin_googlephotos():
auth_file = helper.get_file('plugins/googlephotos/auth_file.json')
Expand Down