test(s36): value-level guard for _ore_to_kr_str money formatter
Closes the one MAJOR from /trekreview of S3.6 (verdict WARN): the user-facing NOK-string formatter had only an isinstance(...,str) check, so a regression (wrong divmod, dropped padding, øre/kr transposition, or non-breaking-space → ASCII) would ship a wrong money figure with the suite green. Adds a load-bearing value-level test (thousands grouping, sub-100-øre padding, negative-sign branch) pinning the actual Norwegian \xa0-separated formatting; verified red under a divmod(...,1000) mutation and reverted. Suite 333 passed / 4 skipped, ruff+mypy clean. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0145ZKPLMVeqM47z2jxxokym
This commit is contained in:
parent
76d9f793c6
commit
0670b2a6d8
1 changed files with 14 additions and 0 deletions
|
|
@ -92,6 +92,20 @@ def test_estimate_table_structure() -> None:
|
|||
assert table["pricing_source"] == "unit-test prices"
|
||||
|
||||
|
||||
def test_ore_to_kr_str_formats_money() -> None:
|
||||
"""Value-level guard for the single money-display edge (``_ore_to_kr_str``): the integer-øre
|
||||
total → user-facing NOK string. Pins the actual Norwegian formatting — non-breaking-space (\\xa0)
|
||||
thousands separator + comma decimals — so a regression (wrong ``divmod``, dropped padding,
|
||||
øre/kr transposition, or the \\xa0 → ASCII space) fails loudly instead of shipping a wrong figure.
|
||||
A structural ``isinstance(..., str)`` check cannot catch any of those."""
|
||||
# thousands grouping (docstring's own worked example)
|
||||
assert costsim._ore_to_kr_str(123456) == "1\xa0234,56\xa0kr"
|
||||
# sub-100-øre → two-digit zero-padded rest
|
||||
assert costsim._ore_to_kr_str(5) == "0,05\xa0kr"
|
||||
# negative-sign branch
|
||||
assert costsim._ore_to_kr_str(-123456) == "-1\xa0234,56\xa0kr"
|
||||
|
||||
|
||||
def test_cli_prints_estimate_table(capsys: pytest.CaptureFixture[str]) -> None:
|
||||
"""CLI smoke: ``main`` prints the estimate table + kost-mot-verdi + adoption footer, rc 0."""
|
||||
rc = costsim.main(["--projects", "4", "--profile", "local"])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue