test: skip watermark integration when darktable export fails

Add darktable style probe and pytest integration/slow markers so CI and
machines without a working darktable-cli setup skip the full workflow test.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Frank Schwenk
2026-07-18 17:34:19 +02:00
parent fd4658434a
commit 92337b7dbc
2 changed files with 66 additions and 19 deletions
+53
View File
@@ -0,0 +1,53 @@
"""Shared helpers for integration tests."""
from __future__ import annotations
import shutil
import subprocess
import tempfile
from pathlib import Path
from tests.conftest import make_png
def has_darktable_style(style_name: str, config_dir: Path | None = None) -> bool:
"""Return True if darktable-cli can apply ``style_name`` to a tiny PNG."""
if not shutil.which("darktable-cli"):
return False
config = config_dir or Path.home() / ".config" / "darktable"
styles_dir = config / "styles"
if not styles_dir.is_dir():
return False
if not any(p.stem == style_name for p in styles_dir.glob("*.dtstyle")):
return False
with tempfile.TemporaryDirectory() as tmp:
tmp_path = Path(tmp)
src = tmp_path / "probe.png"
out_dir = tmp_path / "out"
out_dir.mkdir()
make_png(src)
cmd = [
"darktable-cli",
str(src),
str(out_dir),
"--style",
style_name,
"--out-ext",
"png",
"--core",
"--configdir",
str(config),
"--style-overwrite",
]
result = subprocess.run(cmd, capture_output=True, text=True)
if result.returncode != 0:
return False
return any(out_dir.iterdir())
def has_workflow_tools() -> bool:
"""True when rembg, gmic, ImageMagick, and darktable-cli are on PATH."""
has_magick = bool(shutil.which("magick") or shutil.which("convert"))
return all(shutil.which(name) for name in ("rembg", "gmic", "darktable-cli")) and has_magick