Feature add import 754 (#762)
* Initial alpha version of import command * Refactored * Improved help, added --clear-metadata * Added --clear-metadata, --exiftool to import * Added --keyword, --title, --description * Added --location * Added test for --location * Changed --auto-folder to --split-folder, added docs * Added --walk, updated docs * Added --check-templates * Updated help text for import
This commit is contained in:
@@ -15,6 +15,9 @@ from .test_catalina_10_15_7 import UUID_DICT_LOCAL
|
||||
# run timewarp tests (configured with --timewarp)
|
||||
TEST_TIMEWARP = False
|
||||
|
||||
# run import tests (configured with --import)
|
||||
TEST_IMPORT = False
|
||||
|
||||
# don't clean up crash logs (configured with --no-cleanup)
|
||||
NO_CLEANUP = False
|
||||
|
||||
@@ -42,6 +45,7 @@ def get_os_version():
|
||||
OS_VER = get_os_version()[1]
|
||||
if OS_VER == "15":
|
||||
TEST_LIBRARY = "tests/Test-10.15.7.photoslibrary"
|
||||
TEST_LIBRARY_IMPORT = TEST_LIBRARY
|
||||
from tests.config_timewarp_catalina import TEST_LIBRARY_TIMEWARP
|
||||
else:
|
||||
TEST_LIBRARY = None
|
||||
@@ -56,6 +60,13 @@ def setup_photos_timewarp():
|
||||
copy_photos_library(TEST_LIBRARY_TIMEWARP, delay=10)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session", autouse=True)
|
||||
def setup_photos_import():
|
||||
if not TEST_IMPORT:
|
||||
return
|
||||
copy_photos_library(TEST_LIBRARY_IMPORT, delay=10)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def reset_singletons():
|
||||
"""Need to clean up any ExifTool singletons between tests"""
|
||||
@@ -72,6 +83,12 @@ def pytest_addoption(parser):
|
||||
parser.addoption(
|
||||
"--timewarp", action="store_true", default=False, help="run --timewarp tests"
|
||||
)
|
||||
parser.addoption(
|
||||
"--test-import",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="run `osxphotos import` tests",
|
||||
)
|
||||
parser.addoption(
|
||||
"--no-cleanup",
|
||||
action="store_true",
|
||||
@@ -81,8 +98,18 @@ def pytest_addoption(parser):
|
||||
|
||||
|
||||
def pytest_configure(config):
|
||||
if config.getoption("--addalbum") and config.getoption("--timewarp"):
|
||||
pytest.exit("--addalbum and --timewarp are mutually exclusive")
|
||||
if (
|
||||
sum(
|
||||
bool(x)
|
||||
for x in [
|
||||
config.getoption("--addalbum"),
|
||||
config.getoption("--timewarp"),
|
||||
config.getoption("--test-import"),
|
||||
]
|
||||
)
|
||||
> 1
|
||||
):
|
||||
pytest.exit("--addalbum, --timewarp, --test-import are mutually exclusive")
|
||||
|
||||
config.addinivalue_line(
|
||||
"markers", "addalbum: mark test as requiring --addalbum to run"
|
||||
@@ -90,12 +117,19 @@ def pytest_configure(config):
|
||||
config.addinivalue_line(
|
||||
"markers", "timewarp: mark test as requiring --timewarp to run"
|
||||
)
|
||||
config.addinivalue_line(
|
||||
"markers", "test_import: mark test as requiring --test-import to run"
|
||||
)
|
||||
|
||||
# this is hacky but I can't figure out how to check config options in other fixtures
|
||||
if config.getoption("--timewarp"):
|
||||
global TEST_TIMEWARP
|
||||
TEST_TIMEWARP = True
|
||||
|
||||
if config.getoption("--test-import"):
|
||||
global TEST_IMPORT
|
||||
TEST_IMPORT = True
|
||||
|
||||
if config.getoption("--no-cleanup"):
|
||||
global NO_CLEANUP
|
||||
NO_CLEANUP = True
|
||||
@@ -118,6 +152,14 @@ def pytest_collection_modifyitems(config, items):
|
||||
if "timewarp" in item.keywords:
|
||||
item.add_marker(skip_timewarp)
|
||||
|
||||
if not (config.getoption("--test-import") and TEST_LIBRARY_IMPORT is not None):
|
||||
skip_test_import = pytest.mark.skip(
|
||||
reason="need --test-import option and MacOS Catalina to run"
|
||||
)
|
||||
for item in items:
|
||||
if "test_import" in item.keywords:
|
||||
item.add_marker(skip_test_import)
|
||||
|
||||
|
||||
def copy_photos_library(photos_library, delay=0):
|
||||
"""copy the test library and open Photos, returns path to copied library"""
|
||||
|
||||
Reference in New Issue
Block a user