keys-Auto-Receipts-Studio / tests /test_watcher.py
drowzeys's picture
v1.0 alpha: keys-Auto Receipts Studio (iPhone / may add Autonomous Lamp Skill)
2edb151 verified
Raw
History Blame Contribute Delete
811 Bytes
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