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
+29
View File
@@ -1,6 +1,7 @@
"""Unit tests for the inventory scanner module."""
import os
import threading
import tempfile
import time
import csv
@@ -286,6 +287,34 @@ class TestScanLibrary:
assert result == []
assert progress_events == [(0, 0)]
def test_scan_metadata_parallelism_uses_multiple_threads(self, tmp_path):
"""Metadata scan should use worker threads when concurrency > 1."""
config = Config(library_root=tmp_path, enrichment_max_concurrency=4)
fake_paths = [tmp_path / f"f{i}.mp4" for i in range(8)]
thread_ids: set[int] = set()
lock = threading.Lock()
def _fake_create(file_path, library_root, categories_config, include_video_metadata=True, metadata_cache=None):
time.sleep(0.01)
with lock:
thread_ids.add(threading.get_ident())
return VideoFile(
path=file_path,
filename=file_path.name,
size_bytes=1,
modified_timestamp=datetime.now(timezone.utc),
category="movie",
)
with patch("vlm.scanner._discover_video_paths", return_value=fake_paths), patch(
"vlm.scanner._create_video_file",
side_effect=_fake_create,
):
result = scan_library(tmp_path, config, include_video_metadata=True)
assert len(result) == len(fake_paths)
assert len(thread_ids) > 1
class TestCategorizeFile:
"""Tests for the categorize_file function."""