@@ -12,8 +12,12 @@ from osxphotos.exiftool import _ExifToolProc
|
||||
|
||||
from .test_catalina_10_15_7 import UUID_DICT_LOCAL
|
||||
|
||||
# run timewarp tests (configured with --timewarp)
|
||||
TEST_TIMEWARP = False
|
||||
|
||||
# don't clean up crash logs (configured with --no-cleanup)
|
||||
NO_CLEANUP = False
|
||||
|
||||
|
||||
def get_os_version():
|
||||
import platform
|
||||
@@ -68,6 +72,12 @@ def pytest_addoption(parser):
|
||||
parser.addoption(
|
||||
"--timewarp", action="store_true", default=False, help="run --timewarp tests"
|
||||
)
|
||||
parser.addoption(
|
||||
"--no-cleanup",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="don't clean up crash logs after tests",
|
||||
)
|
||||
|
||||
|
||||
def pytest_configure(config):
|
||||
@@ -81,10 +91,15 @@ def pytest_configure(config):
|
||||
"markers", "timewarp: mark test as requiring --timewarp 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("--no-cleanup"):
|
||||
global NO_CLEANUP
|
||||
NO_CLEANUP = True
|
||||
|
||||
|
||||
def pytest_collection_modifyitems(config, items):
|
||||
if not (config.getoption("--addalbum") and TEST_LIBRARY is not None):
|
||||
@@ -163,7 +178,7 @@ def delete_crash_logs():
|
||||
"""Delete left over crash logs from tests that were supposed to crash"""
|
||||
yield
|
||||
path = pathlib.Path(os.getcwd()) / "osxphotos_crash.log"
|
||||
if path.is_file():
|
||||
if path.is_file() and not NO_CLEANUP:
|
||||
path.unlink()
|
||||
|
||||
|
||||
|
||||
@@ -7715,3 +7715,60 @@ def test_export_added_in_last():
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
assert "Exporting" in result.output
|
||||
|
||||
|
||||
def test_export_limit():
|
||||
"""test export --limit"""
|
||||
|
||||
# Use --added-before so test doesn't break if photos added in the future
|
||||
|
||||
runner = CliRunner()
|
||||
cwd = os.getcwd()
|
||||
with runner.isolated_filesystem():
|
||||
result = runner.invoke(
|
||||
export,
|
||||
[
|
||||
".",
|
||||
"--db",
|
||||
os.path.join(cwd, PHOTOS_DB_15_7),
|
||||
"--update",
|
||||
"--limit",
|
||||
"20",
|
||||
"--added-before",
|
||||
"2022-05-07",
|
||||
],
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
assert "limit: 20/20 exported" in result.output
|
||||
|
||||
result = runner.invoke(
|
||||
export,
|
||||
[
|
||||
".",
|
||||
"--db",
|
||||
os.path.join(cwd, PHOTOS_DB_15_7),
|
||||
"--update",
|
||||
"--limit",
|
||||
"20",
|
||||
"--added-before",
|
||||
"2022-05-07",
|
||||
],
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
assert "limit: 5/20 exported" in result.output
|
||||
|
||||
result = runner.invoke(
|
||||
export,
|
||||
[
|
||||
".",
|
||||
"--db",
|
||||
os.path.join(cwd, PHOTOS_DB_15_7),
|
||||
"--update",
|
||||
"--limit",
|
||||
"20",
|
||||
"--added-before",
|
||||
"2022-05-07",
|
||||
],
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
assert "limit: 0/20 exported" in result.output
|
||||
|
||||
Reference in New Issue
Block a user