portfolio-optimiser/tests/test_run_smoke.py
Kjell Tore Guttormsen 37547fe292
refactor(examples): replace sector-specific example material with generic, fictitious examples
The context sets, the packaged knowledge bases and the example bundles are
replaced by one fictitious example set about IT operations in an invented
organisation: three context sets (serverrom-2027, driftsavtale-2027 and the
two-base drift-og-avtale-2027), two synthetic knowledge bases under
src/portfolio_optimiser/data/kunnskapsbaser and two example bundles under
src/portfolio_optimiser/data/bundles. Numbers, codes and structural values in
tests and fixtures are kept; names, ids and wording change. Dated measurement
documents that only recorded runs on the replaced material are deleted.

Gate figures measured on the new set are not comparable with earlier ones.
The exclusion gate from the previous commit is green: 0 tracked files hit
outside the shared/ subtree.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 15:04:21 +02:00

40 lines
1.4 KiB
Python

"""Step 12 smoke — run_project composes the slice end-to-end on an injected FakeChatClient.
Returns a ValidatedProposal with a populated first-class ProvenanceStamp. Pattern:
tests/test_smoke.py.
"""
from spikes._harness import FakeChatClient
from portfolio_optimiser.provenance import ProvenanceStamp
from portfolio_optimiser.run import run_project
from portfolio_optimiser.validator import ValidatedProposal
_VALID = (
'{"project_id":"KONTOR-IT-E1","measure":"Reduce scope",'
'"affected_items":[{"code":"05.2","quantity":4300,"unit_cost":215},'
'{"code":"03.1","quantity":1800,"unit_cost":310}],"claimed_saving_nok":200000}'
)
async def test_run_project_smoke(tmp_path) -> None:
docs = tmp_path / "docs"
docs.mkdir()
(docs / "cost.txt").write_text(
"Licence unit price renegotiation reduced the office-suite cost for the head office.",
encoding="utf-8",
)
def factory(role: str) -> FakeChatClient:
return FakeChatClient(default_reply=_VALID)
result = await run_project(
"KONTOR-IT-E1",
"local",
docs_dir=str(docs),
verdict_input={"decision": "approved", "rationale": "feasible within range"},
client_factory=factory,
)
assert isinstance(result.outcome, ValidatedProposal)
assert isinstance(result.provenance, ProvenanceStamp)
assert len(result.provenance.citations) >= 1