chore: snapshot current project updates

This commit is contained in:
windyboy
2026-02-13 13:36:39 +08:00
parent 5931f16a71
commit 0be802eac5
74 changed files with 594899 additions and 66082 deletions
+43
View File
@@ -1,6 +1,7 @@
"""Unit tests for State Store operations."""
import json
import os
import pytest
from datetime import datetime, timezone
from pathlib import Path
@@ -387,3 +388,45 @@ class TestStateManager:
results = manager.query_by_status(status)
expected_count = sum(1 for _, s in files if s == status)
assert len(results) == expected_count
def test_set_file_state_uses_canonical_key_for_symlink_paths(self, tmp_path):
"""Setting state through symlink and real path should deduplicate keys."""
real_dir = tmp_path / "real"
real_dir.mkdir()
real_file = real_dir / "movie.mkv"
real_file.write_text("x")
link_dir = tmp_path / "link"
os.symlink(real_dir, link_dir)
symlink_file = link_dir / "movie.mkv"
manager = StateManager(tmp_path / "state.json")
manager.set_file_state(symlink_file, "reviewed", "via symlink")
manager.set_file_state(real_file, "ignored", "via real path")
assert len(manager.store.states) == 1
state = manager.get_file_state(real_file)
assert state is not None
assert state.status == "ignored"
def test_save_state_uses_atomic_replace(tmp_path, monkeypatch):
"""save_state should atomically replace the destination file."""
state_path = tmp_path / "state.json"
replaced = {"called": False}
original_replace = os.replace
def _replace(src, dst):
replaced["called"] = True
return original_replace(src, dst)
monkeypatch.setattr("vlm.state.os.replace", _replace)
manager = StateManager(state_path)
manager.set_file_state(Path("/videos/movie.mp4"), "reviewed", "atomic")
manager.save()
assert replaced["called"] is True
loaded = load_state(state_path)
assert len(loaded.states) == 1