From 09687cfca43104045e2a649af9f717775f2c0228 Mon Sep 17 00:00:00 2001 From: Rhet Turnbull Date: Fri, 11 Dec 2020 06:12:32 -0800 Subject: [PATCH] Initial test for --save-config, --load-config --- tests/test_cli.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/tests/test_cli.py b/tests/test_cli.py index a2db68c7..df5b4ee2 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -3961,3 +3961,49 @@ def test_export_cleanup(): assert not pathlib.Path("./delete_me.txt").is_file() assert not pathlib.Path("./foo/delete_me_too.txt").is_file() + +def test_save_load_config(): + """ test --save-config, --load-config """ + import glob + import os + import os.path + import osxphotos + from osxphotos.__main__ import export + + runner = CliRunner() + cwd = os.getcwd() + # pylint: disable=not-context-manager + with runner.isolated_filesystem(): + result = runner.invoke( + export, + [ + os.path.join(cwd, CLI_PHOTOS_DB), + ".", + "-V", + "--sidecar", + "XMP", + "--touch-file", + "--update", + "--save-config", + "config.toml", + ], + ) + assert result.exit_code == 0 + assert "Saving options to file" in result.output + files = glob.glob("*") + assert "config.toml" in files + + result = runner.invoke( + export, + [ + os.path.join(cwd, CLI_PHOTOS_DB), + ".", + "-V", + "--load-config", + "config.toml", + ], + ) + assert result.exit_code == 0 + assert "Loaded options from file" in result.output + assert "Skipped up to date XMP sidecar" in result.output +