Download tests/test_watcher.py from drowzeys/keys-Auto-Receipts-Studio: direct link, hf CLI and curl.
- Browser
- Download file 811 Bytes
-
https://huggingface.co/drowzeys/keys-Auto-Receipts-Studio/resolve/main/tests/test_watcher.py
- Command line
-
hf download hf://drowzeys/keys-Auto-Receipts-Studio/tests/test_watcher.py
-
curl -L -o test_watcher.py https://huggingface.co/drowzeys/keys-Auto-Receipts-Studio/resolve/main/tests/test_watcher.py
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 | |