mirror of
https://github.com/lllin000/PaperForge.git
synced 2026-07-22 06:50:53 +00:00
49 lines
1.6 KiB
Python
49 lines
1.6 KiB
Python
from __future__ import annotations
|
|
|
|
import json
|
|
|
|
from paperforge.memory.runtime_health import (
|
|
_check_bootstrap,
|
|
_check_write,
|
|
get_runtime_health,
|
|
)
|
|
|
|
|
|
def test_runtime_health_blocks_without_paperforge_json(tmp_path):
|
|
vault = tmp_path / "novault"
|
|
vault.mkdir()
|
|
health = get_runtime_health(vault)
|
|
assert health["summary"]["status"] == "blocked"
|
|
assert health["layers"]["bootstrap"]["status"] == "blocked"
|
|
assert health["capabilities"]["paper_context"] == False
|
|
|
|
|
|
def test_bootstrap_with_paperforge_json(tmp_path):
|
|
vault = tmp_path / "vault"
|
|
vault.mkdir()
|
|
pf_json = vault / "paperforge.json"
|
|
pf_json.write_text(json.dumps({"system_dir": "System"}), encoding="utf-8")
|
|
(vault / "System" / "PaperForge").mkdir(parents=True)
|
|
result = _check_bootstrap(vault)
|
|
assert result["status"] == "ok"
|
|
|
|
|
|
def test_write_layer(tmp_path):
|
|
vault = tmp_path / "vault"
|
|
vault.mkdir()
|
|
result = _check_write(vault)
|
|
assert result["status"] == "ok"
|
|
assert any("writable" in e for e in result["evidence"])
|
|
|
|
|
|
def test_runtime_health_summary_has_expected_keys(tmp_path):
|
|
vault = tmp_path / "vault"
|
|
vault.mkdir()
|
|
health = get_runtime_health(vault)
|
|
summary = health["summary"]
|
|
for key in ("status", "reason", "safe_read", "safe_write", "safe_build", "safe_vector"):
|
|
assert key in summary
|
|
for layer in ("bootstrap", "read", "write", "index", "vector"):
|
|
assert layer in health["layers"]
|
|
for key in ("status", "evidence", "next_action", "repair_command"):
|
|
assert key in health["layers"][layer]
|