| 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 | |