27 lines
933 B
Python
27 lines
933 B
Python
import json
|
|
from tht.cli.sql_cmd import promoted_columns_for
|
|
|
|
|
|
def test_promoted_columns_for(tmp_path):
|
|
sid = "2026-07-16-120000"
|
|
sdir = tmp_path / sid
|
|
sdir.mkdir(parents=True)
|
|
(sdir / "session_manifest.yaml").write_text(
|
|
f"id: {sid}\nquestion: q\ndatabase: d\nschema: s\n"
|
|
"created_at: 2026-01-01T00:00:00+00:00\nstatus: open\n"
|
|
)
|
|
(sdir / "schema_linking.json").write_text(json.dumps({
|
|
"question": "q",
|
|
"candidates": [
|
|
{"kind": "table", "name": "dim_patient", "decision": "promoted"},
|
|
{"kind": "column", "name": "dim_patient.cod_paz", "decision": "promoted"},
|
|
{"kind": "column", "name": "dim_patient.nome", "decision": "excluded"},
|
|
],
|
|
"joins": [], "excluded": [],
|
|
}))
|
|
|
|
class Cfg:
|
|
class paths: # noqa: N801
|
|
sessions = tmp_path
|
|
assert promoted_columns_for(Cfg, sid) == {"dim_patient.cod_paz"}
|