feat: harden runtime readiness and session workflow
This commit is contained in:
@@ -163,3 +163,43 @@ def test_cli_show_json_stdout_pristine(tmp_path, monkeypatch):
|
||||
# stdout must parse cleanly as JSON
|
||||
data = json.loads(result.output)
|
||||
assert isinstance(data, dict)
|
||||
|
||||
|
||||
def test_cli_retrieval_pack_emits_persisted_content(tmp_path, monkeypatch):
|
||||
db = _make_db()
|
||||
manifest = create_session("test question", db, tmp_path)
|
||||
expected = "# Retrieval pack\n\ncontenuto già pronto\n"
|
||||
(tmp_path / manifest.id / "retrieval_pack.md").write_text(expected)
|
||||
|
||||
from tht.cli import session_cmd
|
||||
|
||||
class FakePaths:
|
||||
sessions = tmp_path
|
||||
|
||||
class FakeCfg:
|
||||
paths = FakePaths()
|
||||
|
||||
monkeypatch.setattr(session_cmd, "_load_config_or_exit", lambda _: FakeCfg())
|
||||
result = CliRunner().invoke(session_app, ["retrieval-pack", manifest.id])
|
||||
|
||||
assert result.exit_code == 0, result.output
|
||||
assert result.output == expected
|
||||
|
||||
|
||||
def test_cli_retrieval_pack_missing_is_clear_error(tmp_path, monkeypatch):
|
||||
db = _make_db()
|
||||
manifest = create_session("test question", db, tmp_path)
|
||||
|
||||
from tht.cli import session_cmd
|
||||
|
||||
class FakePaths:
|
||||
sessions = tmp_path
|
||||
|
||||
class FakeCfg:
|
||||
paths = FakePaths()
|
||||
|
||||
monkeypatch.setattr(session_cmd, "_load_config_or_exit", lambda _: FakeCfg())
|
||||
result = CliRunner().invoke(session_app, ["retrieval-pack", manifest.id])
|
||||
|
||||
assert result.exit_code == 1
|
||||
assert "retrieval pack non disponibile" in result.output
|
||||
|
||||
Reference in New Issue
Block a user