Feature catch template error (#1141)

* Starting to implement catch_errors for sidecar_template

* Fixed error printing

* Fixed error printing

* Added tests for catch_errors
This commit is contained in:
Rhet Turnbull
2023-08-03 06:33:17 -07:00
committed by GitHub
parent e937285a72
commit 93e1966607
5 changed files with 89 additions and 12 deletions

View File

@@ -544,3 +544,51 @@ def test_export_sidecar_template_skip_zero():
sidecar_file = pathlib.Path(SIDECAR_FILENAME_NO_KEYWORD)
assert not sidecar_file.exists()
def test_export_sidecar_template_error():
"""test basic export with --sidecar-template that generates an error"""
runner = CliRunner()
cwd = os.getcwd()
# pylint: disable=not-context-manager
with runner.isolated_filesystem():
result = runner.invoke(
export,
[
"--library",
os.path.join(cwd, PHOTOS_DB),
".",
"-V",
"--uuid",
PHOTO_UUID,
"--sidecar-template",
os.path.join(cwd, "tests", "custom_sidecar_bad.mako"),
"{filepath}.txt",
"none",
],
)
assert result.exit_code != 0
def test_export_sidecar_template_catch_error():
"""test basic export with --sidecar-template that catches an error"""
runner = CliRunner()
cwd = os.getcwd()
# pylint: disable=not-context-manager
with runner.isolated_filesystem():
result = runner.invoke(
export,
[
"--library",
os.path.join(cwd, PHOTOS_DB),
".",
"-V",
"--uuid",
PHOTO_UUID,
"--sidecar-template",
os.path.join(cwd, "tests", "custom_sidecar_bad.mako"),
"{filepath}.txt",
"catch_errors",
],
)
assert result.exit_code == 0