This commit is contained in:
Rhet Turnbull
2021-05-28 08:48:21 -07:00
parent b026147c9a
commit 2d68594b78
5 changed files with 38 additions and 26 deletions

View File

@@ -3,9 +3,10 @@ import os
import pathlib
import pytest
from applescript import AppleScript
from photoscript.utils import ditto
import osxphotos
from applescript import AppleScript
from osxphotos.exiftool import _ExifToolProc
@@ -63,7 +64,9 @@ def pytest_collection_modifyitems(config, items):
# --addalbum given in cli: do not skip addalbum tests (these require interactive test)
return
skip_addalbum = pytest.mark.skip(reason="need --addalbum option and MacOS Catalina to run")
skip_addalbum = pytest.mark.skip(
reason="need --addalbum option and MacOS Catalina to run"
)
for item in items:
if "addalbum" in item.keywords:
item.add_marker(skip_addalbum)

View File

@@ -34,9 +34,9 @@ UUID_BURST_ALBUM = {
"TestBurst2/IMG_9814.JPG",
],
"38F8F30C-FF6D-49DA-8092-18497F1D6628": [
"TestBurst/IMG_9812.JPG",
"TestBurst/IMG_9812.JPG",
"TestBurst/IMG_9813.JPG",
"TestBurst/IMG_9814.JPG", # in my personal library, "38F8F30C-FF6D-49DA-8092-18497F1D6628"
"TestBurst/IMG_9814.JPG", # in my personal library, "38F8F30C-FF6D-49DA-8092-18497F1D6628"
"TestBurst/IMG_9815.JPG",
"TestBurst/IMG_9816.JPG",
"TestBurst2/IMG_9814.JPG",
@@ -1229,16 +1229,12 @@ def test_export_exiftool_path():
import shutil
import tempfile
from osxphotos.cli import export
from osxphotos.exiftool import ExifTool, get_exiftool_path
from osxphotos.exiftool import ExifTool
runner = CliRunner()
cwd = os.getcwd()
# pylint: disable=not-context-manager
with runner.isolated_filesystem():
tempdir = tempfile.TemporaryDirectory()
exiftool_source = get_exiftool_path()
exiftool_path = os.path.join(tempdir.name, "myexiftool")
shutil.copy2(exiftool_source, exiftool_path)
for uuid in CLI_EXIFTOOL:
result = runner.invoke(
export,
@@ -1250,11 +1246,11 @@ def test_export_exiftool_path():
"--uuid",
f"{uuid}",
"--exiftool-path",
exiftool_path,
exiftool,
],
)
assert result.exit_code == 0
assert f"exiftool path: {exiftool_path}" in result.output
assert f"exiftool path: {exiftool}" in result.output
files = glob.glob("*")
assert sorted(files) == sorted([CLI_EXIFTOOL[uuid]["File:FileName"]])
@@ -1290,9 +1286,6 @@ def test_export_exiftool_path_render_template():
cwd = os.getcwd()
# pylint: disable=not-context-manager
with runner.isolated_filesystem():
tempdir = tempfile.TemporaryDirectory()
exiftool_path = os.path.join(tempdir.name, "myexiftool")
shutil.copy2(exiftool_source, exiftool_path)
for uuid in CLI_EXIFTOOL:
result = runner.invoke(
export,
@@ -1305,7 +1298,7 @@ def test_export_exiftool_path_render_template():
"--uuid",
f"{uuid}",
"--exiftool-path",
exiftool_path,
exiftool,
],
)
assert result.exit_code == 0

View File

@@ -425,8 +425,17 @@ def test_exiftool_terminate():
import subprocess
exif1 = osxphotos.exiftool.ExifTool(TEST_FILE_ONE_KEYWORD)
ps = subprocess.run(["ps"], capture_output=True)
stdout = ps.stdout.decode("utf-8")
assert "exiftool -stay_open" in stdout
osxphotos.exiftool.terminate_exiftool()
ps = subprocess.run(["ps"], capture_output=True)
stdout = ps.stdout.decode("utf-8")
assert "exiftool -stay_open" not in stdout
# verify we can create a new instance after termination
exif2 = osxphotos.exiftool.ExifTool(TEST_FILE_ONE_KEYWORD)
assert exif2.asdict()["IPTC:Keywords"] == "wedding"