Files
hockey_new/tests/test_build87_penalty_strength_rebalance.py

25 lines
1.1 KiB
Python

from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
APP_JS = (ROOT / "ui_builder/static/app.js").read_text(encoding="utf-8")
def test_authoritative_strength_change_rebalances_penalty_targets():
start = APP_JS.index("function hockeyStoreGameControl")
end = APP_JS.index("async function hockeyLoadGameControl", start)
block = APP_JS[start:end]
assert "const strengthChanged" in block
assert "hockeyStrengthMappingSignature(previousControl) !== hockeyStrengthMappingSignature(payload)" in block
assert "rebalanceVmixPenaltyTargets({ force: true, hideUnused: true })" in block
assert "Penalty strength rebalance error" in block
def test_penalty_plan_rebalances_after_strength_refresh_without_forcing_complex_powerplay():
start = APP_JS.index("function penaltyDisplayEntriesByTargetSide")
end = APP_JS.index("function hockeyPenaltySideMappingDetail", start)
block = APP_JS[start:end]
assert 'if (home.length && away.length)' in block
assert 'routedToAdvantage: false' in block
assert 'if (home.length)' in block
assert 'if (away.length)' in block