diff --git a/goodwe_controller/test_opt36.py b/goodwe_controller/test_opt36.py index 8e42a22..c12a460 100644 --- a/goodwe_controller/test_opt36.py +++ b/goodwe_controller/test_opt36.py @@ -40,6 +40,7 @@ sys.path.insert(0, HERE) sys.path.insert(0, os.path.join(HERE, "tools")) logging.disable(logging.WARNING) +from named_absence import nth # noqa: E402 import ux54_scenarios as S # noqa: E402 import opt11p3_replay as rp # noqa: E402 import app.main as m # noqa: E402 @@ -157,10 +158,10 @@ for lang in ("en", "nl"): f"({[r['kind'] for r in mine]})", [r["kind"] for r in mine] == ["give"]) check(f"{lang}: A's give block is what A holds (60 % -> 6.1 kWh)", - abs(mine[0]["kwh"] - (60.0 - FLOOR) / 100.0 * CAP_A) < 0.01) + abs(nth(mine, 0)["kwh"] - (60.0 - FLOOR) / 100.0 * CAP_A) < 0.01) check(f"{lang}: B's give block reads B after its charge (to 95 %: " "15.4 kWh, not 15.2 from 94 %)", - abs(theirs[-1]["kwh"] - (CEIL - FLOOR) / 100.0 * CAP_B) < 0.01) + abs(nth(theirs, -1)["kwh"] - (CEIL - FLOOR) / 100.0 * CAP_B) < 0.01) check(f"{lang}: the solar line has no 'the rest' sentence", "0.4" not in line and "0,4" not in line and "rest, " not in line and "rest van" not in line