lllin000_PaperForge/tests/test_dashboard_command.py
Research Assistant 5ad9a54a66 test: clean up brittle and low-value tests
- Remove 4 broken Python test files (ld_deep x3, path_normalization)
- Fix 2 vector_db tests to use correct mock target (get_collection)
- Remove 2 JS test files (settings-panels, vector-ready — trivial)
- Trim 3 buildRuntimeInstallCommand tests from errors.test.ts
- Narrow CI unit-tests to only run tests/unit/ (gate-level)
2026-05-24 19:59:14 +08:00

30 lines
895 B
Python

from pathlib import Path
from paperforge.commands.dashboard import _dashboard_from_db
def test_dashboard_from_db_uses_configured_system_dir(tmp_path: Path) -> None:
(tmp_path / "paperforge.json").write_text(
'{"vault_config": {"system_dir": "02_文献管理/System"}}',
encoding="utf-8",
)
db_path = tmp_path / "02_文献管理" / "System" / "PaperForge" / "indexes" / "paperforge.db"
db_path.parent.mkdir(parents=True)
import sqlite3
conn = sqlite3.connect(str(db_path))
conn.execute(
"CREATE TABLE papers (domain TEXT, has_pdf INTEGER, ocr_status TEXT)"
)
conn.execute(
"INSERT INTO papers(domain, has_pdf, ocr_status) VALUES (?, ?, ?)",
("Sports", 1, "done"),
)
conn.commit()
conn.close()
data = _dashboard_from_db(tmp_path)
assert data is not None
assert data["stats"]["papers"] == 1