Riduce falsi positivi del watchdog

This commit is contained in:
2026-07-02 09:59:49 +02:00
parent ffdbba2655
commit 2f0a5d53cf
4 changed files with 133 additions and 10 deletions

View File

@@ -24,3 +24,27 @@ def test_mark_ignored_removes_from_pending_queue(tmp_path: Path) -> None:
registry.mark_ignored(path)
assert registry.pending_count() == 0
def test_snapshot_change_detection(tmp_path: Path) -> None:
registry = ChangeRegistry(tmp_path / "changes.sqlite")
path = str(tmp_path / "image.jpg")
assert registry.has_snapshot_changed(path, 100, 123)
registry.update_snapshot(path, 100, 123)
assert not registry.has_snapshot_changed(path, 100, 123)
assert registry.has_snapshot_changed(path, 101, 123)
assert registry.has_snapshot_changed(path, 100, 124)
def test_record_stores_snapshot_and_mtime(tmp_path: Path) -> None:
registry = ChangeRegistry(tmp_path / "changes.sqlite")
path = str(tmp_path / "image.jpg")
registry.record(ChangeEvent(path=path, event_type="modified", size=100, mtime_ns=123))
pending = registry.list_pending()
assert pending == [ChangeEvent(path=path, event_type="modified", size=100, mtime_ns=123)]
assert not registry.has_snapshot_changed(path, 100, 123)