Files
ThothII/harness/tests/test_workflow.py
marcopan fc5fbe6b65 refactor(harness): renaming prodotto tht (Onda -1)
Thoth (tht) è il prodotto, PSD è il cliente. Nessun riferimento al contesto
clinico nel codice.

Rinomine:
- comando+package nsp→tht (dir nsp/→tht/, 46 import, pyproject entry point)
- gate nsp-gate.js→tht-gate.js (+ rewrite token, relayIfNspFails→relayIfThtFails)
- workspace chirone.{example,test}.yaml→tht.{example,test}.yaml (generici)
- env THOTH_→THT_ (19 var) + NSP_ stragglers (NSP_HARNESS_ROOT, NSP_SESSION)
- commenti/docstring chirone/psdwp3/policlinico neutralizzati ('the reference
  implementation', 'the DWH')

Aggiunto [tool.setuptools.packages.find] include=['tht*'] (necessario: l'auto-
discovery rompeva con tht/ + workspaces/ come top-level multipli).

.env operatore aggiornato in-place (prefissi THT_, valori preservati, gitignored).

Verifica: pytest 109 passed, npm test 14 pass, tht phase meta --json OK, zero
residui nsp/THOTH_/NSP_/chirone nel package.
2026-06-27 10:33:16 +02:00

56 lines
2.1 KiB
Python

from tht.workflow import load_workflow
def test_workflow_loads_8_phases():
wf = load_workflow()
assert len(wf.phases) == 8
assert wf.phases[0].id == "F1"
assert wf.max_phase == 8
assert wf.phase_by_num(1).name == "chiarimento"
def test_decision_min_phase_derived():
wf = load_workflow()
# question_rewritten is a prerequisite of F3 -> min phase 3
assert wf.decision_min_phase("question_rewritten") == 3
# sql_approved is a prerequisite of F7 -> min phase 7
assert wf.decision_min_phase("sql_approved") == 7
# datamart_requested / datamart_declined are prerequisites of F8 -> min phase 8
assert wf.decision_min_phase("datamart_requested") == 8
assert wf.decision_min_phase("datamart_declined") == 8
# phase_skipped referenced via decision_subject_exists in F6 -> min phase 6
assert wf.decision_min_phase("phase_skipped") == 6
# unknown type -> phase 1 (default)
assert wf.decision_min_phase("nonexistent_type") == 1
def test_phase_name_lookup():
wf = load_workflow()
assert wf.phase_name(1) == "chiarimento"
assert wf.phase_name(6) == "cte"
assert wf.phase_name(8) == "datamart" # the JS drift bug in ChironeWp3 -- F8 MUST be present
assert wf.phase_name(0) == "?" # out of range lower
assert wf.phase_name(9) == "?" # out of range upper
def test_artifacts_out_per_phase():
wf = load_workflow()
assert "schema_linking.json" in wf.phase_by_num(4).artifacts_out
assert "sql_final.sql" in wf.phase_by_num(7).artifacts_out
assert "cte_plan.json" in wf.phase_by_num(6).artifacts_out
assert "ctes/" in wf.phase_by_num(6).artifacts_out # dir artifact
assert wf.phase_by_num(1).artifacts_out == [] # F1 produces none
def test_advance_strategy_per_phase():
wf = load_workflow()
assert wf.phase_by_num(2).advance == "auto_if_empty"
assert wf.phase_by_num(6).advance == "auto_if_empty_or_skipped"
assert wf.phase_by_num(4).advance == "reviewer_decide"
assert wf.phase_by_num(5).advance == "kind:phase"
def test_schema_version():
wf = load_workflow()
assert wf.schema_version == 1