File size: 811 Bytes
2edb151 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | from __future__ import annotations
from pathlib import Path
from app.config import Settings
from app.watcher import IdleBatchWatcher, is_ignored
def test_ignores_syncthing(tmp_path: Path) -> None:
assert is_ignored(tmp_path / ".syncthing.foo.jpg")
assert is_ignored(tmp_path / "foo.jpg.tmp")
assert not is_ignored(tmp_path / "foo.jpg")
def test_settles_after_idle(settings: Settings) -> None:
inbox = settings.inbox_dir
inbox.mkdir(parents=True, exist_ok=True)
got: list[Path] = []
watcher = IdleBatchWatcher(inbox, idle_seconds=0.05, on_batch=lambda p: got.extend(p))
target = inbox / "a.jpg"
target.write_bytes(b"jpeg")
watcher.tick(now=0.0)
assert got == []
watcher.tick(now=0.01)
assert got == []
watcher.tick(now=0.06)
assert target in got
|