From 2f261f8ba4737f28f36f6b092310818780e83a09 Mon Sep 17 00:00:00 2001 From: glenn schrooyen Date: Wed, 14 Oct 2026 19:58:50 +0200 Subject: [PATCH] PRICE-01 review: spaced-token check passes the length rule; F3 default pinned The spaced-token check used a 5-character token, which the new 16-character rule refuses on its own, so a validator that stopped checking spaces passed (reviewer mutation R06). It now uses a long token and checks the reason. Also pin F3 with no maintenance_enabled key: the default (off) holds and no no-price words show (reviewer mutation S04). Tests only. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Bdqr7PiaHcBnzPituu2yTC --- goodwe_controller/test_price_service.py | 26 ++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/goodwe_controller/test_price_service.py b/goodwe_controller/test_price_service.py index a08dc54..37a58b6 100644 --- a/goodwe_controller/test_price_service.py +++ b/goodwe_controller/test_price_service.py @@ -1224,9 +1224,12 @@ check("...without a token it is refused, naming both settings by label and key " f"({_e})", len(_e) == 1 and "“Dynamic price source” (price_provider)" in _e[0] and "“Price service token” (price_service_token)" in _e[0] and TOKEN not in _e[0]) -check("...a token with a space in it is refused, and the token is not echoed", - len(problems(price_service_token="ab cd")) == 1 - and "ab cd" not in problems(price_service_token="ab cd")[0]) +# Long enough to pass the length rule, so only the space can refuse it. +_SPACED = "tk-0123456789 abcdefgh" +_e = problems(price_service_token=_SPACED) +check("...a token with a space in it is refused for the space, and the token " + "is not echoed", + len(_e) == 1 and "space" in _e[0] and _SPACED not in _e[0]) _e = problems(price_now_entity="sensor.a", price_avg_entity="sensor.b") check(f"the existing conflict refusal stands: the Home Assistant pair beside " f"this provider is refused ({len(_e)} problem)", @@ -1430,6 +1433,23 @@ check("a notification raised while the cycle was on is cleared, once, when " len(_r) == 1 and [x[0] for x in _n] == ["create", "dismiss"] and _g is False) + +async def _scenario_key_missing(): + """No `maintenance_enabled` key at all: its shipped default (off) holds.""" + with Wired(NOW) as W: + c = W.ctl + c.o.pop("maintenance_enabled", None) + W.net.down() + await W.refresh() + for k in range(3): + await W.tick(NOW + timedelta(seconds=30 * k)) + return c.price_gap, list(W.notes()) + + +_g2, _n2 = run(_scenario_key_missing()) +check("with no maintenance_enabled key its default (off) holds: no no-price " + "words, no notification", _g2 is False and _n2 == []) + async def _modes_no_price(): """Battery modes on, maintenance off, no price anywhere: what happens.""" from app import packmode, homeview