удаления еще раз 2
This commit is contained in:
@@ -32,7 +32,7 @@ def test_complex_two_vs_one_keeps_real_strength_and_outputs_caption_on_advantage
|
||||
)
|
||||
assert value["strength_label"] == "3×4"
|
||||
assert value["advantage_side"] == "away"
|
||||
assert value["home_label"] == "4 на 3"
|
||||
assert value["home_label"] == "Играют в большинстве"
|
||||
assert value["away_label"] == "Играют в большинстве"
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ def test_single_remaining_penalty_outputs_pp_caption_on_opposite_team():
|
||||
language="ru",
|
||||
)
|
||||
assert value["advantage_side"] == "away"
|
||||
assert value["home_label"] == "5 на 4"
|
||||
assert value["home_label"] == "Играют в большинстве"
|
||||
assert value["away_label"] == "Играют в большинстве"
|
||||
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ def test_two_vs_one_penalties_caption_only_advantage_team():
|
||||
)
|
||||
assert payload["strength_label"] == "3×4"
|
||||
assert payload["advantage_side"] == "away"
|
||||
assert payload["home_label"] == "4 на 3"
|
||||
assert payload["home_label"] == "Играют в большинстве"
|
||||
assert payload["away_label"] == "Играют в большинстве"
|
||||
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ def test_play_by_play_defaults_collapsed_until_operator_opens_it():
|
||||
|
||||
def test_penalized_side_gets_numeric_condition_and_advantage_side_keeps_pp_caption():
|
||||
payload = _strength(home=1, away=0)
|
||||
assert payload["home_label"] == "5 на 4"
|
||||
assert payload["home_label"] == "Играют в большинстве"
|
||||
assert payload["away_label"] == "Играют в большинстве"
|
||||
|
||||
|
||||
@@ -77,5 +77,5 @@ def test_equal_coincidental_penalties_expose_numeric_condition_on_both_mapping_s
|
||||
|
||||
def test_english_penalty_side_uses_numeric_condition():
|
||||
payload = _strength(home=1, away=0, language="en")
|
||||
assert payload["home_label"] == "5 on 4"
|
||||
assert payload["home_label"] == "Power play"
|
||||
assert payload["away_label"] == "Power play"
|
||||
|
||||
@@ -33,7 +33,7 @@ def payload(home, away, labels=None):
|
||||
|
||||
def test_one_home_penalty_uses_5_on_4_on_penalized_side():
|
||||
result = payload(1, 0)
|
||||
assert result["home_label"] == "5 на 4"
|
||||
assert result["home_label"] == "Играют в большинстве"
|
||||
assert result["away_label"] == "Играют в большинстве"
|
||||
|
||||
|
||||
@@ -53,5 +53,5 @@ def test_complex_two_vs_one_keeps_majority_caption_and_numeric_penalty_side():
|
||||
labels = {"regulation": {"4x3": {"ru": "Большинство 4 на 3"}}}
|
||||
result = payload(2, 1, labels)
|
||||
assert result["advantage_side"] == "away"
|
||||
assert result["home_label"] == "4 на 3"
|
||||
assert result["home_label"] == "Большинство 4 на 3"
|
||||
assert result["away_label"] == "Большинство 4 на 3"
|
||||
|
||||
40
tests/test_build93_countdown_reseed_on_start.py
Normal file
40
tests/test_build93_countdown_reseed_on_start.py
Normal file
@@ -0,0 +1,40 @@
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
APP_JS = (ROOT / "ui_builder/static/app.js").read_text(encoding="utf-8")
|
||||
APP = (ROOT / "app.py").read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def test_game_countdown_resume_is_reseeded_before_start():
|
||||
block = APP_JS.split("async function syncActiveVmixGameCountdown", 1)[1].split("function penaltyMirrorKey", 1)[0]
|
||||
assert '["timer_start", "timer_restart", "timer_resume"].includes(eventName)' in block
|
||||
set_pos = block.index('Function: "SetCountdown"')
|
||||
start_pos = block.index('Function: "StartCountdown"')
|
||||
assert set_pos < start_pos
|
||||
assert 'eventName === "timer_resume"' not in block
|
||||
|
||||
|
||||
def test_hockey_timer_shortcut_reseeds_game_and_penalty_on_resume():
|
||||
block = APP_JS.split('case "hockey_vmix_timers_start":', 1)[1].split('case "delay":', 1)[0]
|
||||
# Resume must no longer have a StartCountdown-only branch.
|
||||
assert '} else if (action === "resume") {' not in block
|
||||
assert block.count('Function: "SetCountdown"') >= 2
|
||||
assert block.count('Function: "StartCountdown"') >= 2
|
||||
|
||||
|
||||
def test_penalty_rebalance_pairs_every_start_with_current_web_value():
|
||||
block = APP_JS.split("async function rebalanceVmixPenaltyTargets", 1)[1].split("function currentHockeyPenaltyEntries", 1)[0]
|
||||
assert "const startingCountdown" in block
|
||||
assert "force || assignmentChanged || startingCountdown" in block
|
||||
assert 'Function: "SetCountdown"' in block
|
||||
assert 'Function: "StartCountdown"' in block
|
||||
|
||||
|
||||
def test_native_mode_still_has_no_per_second_countdown_transport():
|
||||
assert 'eventName === "timer_tick" && state.vmixTimerMirrors.has(component.action_id)' in APP_JS
|
||||
tick_branch = APP_JS.split('eventName === "timer_tick" && state.vmixTimerMirrors.has(component.action_id)', 1)[1].split('} else if (eventName !== "timer_tick"', 1)[0]
|
||||
assert "SetCountdown" not in tick_branch
|
||||
|
||||
|
||||
def test_build93_runtime_version():
|
||||
assert 'BUILD_VERSION = "2026.08.20.14"' in APP
|
||||
84
tests/test_build94_strength_labels_from_settings.py
Normal file
84
tests/test_build94_strength_labels_from_settings.py
Normal file
@@ -0,0 +1,84 @@
|
||||
from hockey_data.service import HockeyDataService
|
||||
|
||||
|
||||
def penalty(side: str):
|
||||
return {
|
||||
"side": side,
|
||||
"infraction": {"id": "minor"},
|
||||
"preset": "2m",
|
||||
"durationMs": 120000,
|
||||
"remainingMs": 120000,
|
||||
"finished": False,
|
||||
}
|
||||
|
||||
|
||||
def strength(settings, *, home=0, away=0, language="ru"):
|
||||
timer_state = {
|
||||
"penalty_board": {
|
||||
"penalties": [penalty("home") for _ in range(home)] + [penalty("away") for _ in range(away)]
|
||||
}
|
||||
}
|
||||
base = {
|
||||
"strength_regulation_skaters": 5,
|
||||
"strength_regular_overtime_skaters": 3,
|
||||
"strength_playoff_overtime_skaters": 5,
|
||||
"strength_min_skaters": 3,
|
||||
}
|
||||
base.update(settings)
|
||||
return HockeyDataService._strength_payload(
|
||||
base, stage="regular", current_period="1", timer_state=timer_state, language=language
|
||||
)
|
||||
|
||||
|
||||
def test_home_and_away_labels_use_exact_configured_strength_caption():
|
||||
result = strength({
|
||||
"strength_state_labels": {
|
||||
"regulation": {"5x4": {"ru": "МОЯ ПОДПИСЬ 5x4", "en": "MY 5x4 CAPTION"}}
|
||||
}
|
||||
}, home=1)
|
||||
assert result["state_key"] == "5x4"
|
||||
assert result["state_label"] == "МОЯ ПОДПИСЬ 5x4"
|
||||
assert result["home_label"] == "МОЯ ПОДПИСЬ 5x4"
|
||||
assert result["away_label"] == "МОЯ ПОДПИСЬ 5x4"
|
||||
|
||||
|
||||
def test_complex_strength_uses_configured_caption_without_numeric_regeneration():
|
||||
result = strength({
|
||||
"strength_state_labels": {
|
||||
"regulation": {"4x3": {"ru": "СТУДИЙНОЕ 4x3", "en": "STUDIO 4x3"}}
|
||||
}
|
||||
}, home=2, away=1)
|
||||
assert result["advantage_side"] == "away"
|
||||
assert result["state_label"] == "СТУДИЙНОЕ 4x3"
|
||||
assert result["home_label"] == "СТУДИЙНОЕ 4x3"
|
||||
assert result["away_label"] == "СТУДИЙНОЕ 4x3"
|
||||
|
||||
|
||||
def test_explicit_empty_strength_caption_remains_empty_everywhere():
|
||||
result = strength({
|
||||
"strength_state_labels": {
|
||||
"regulation": {"5x4": {"ru": "", "en": ""}}
|
||||
}
|
||||
}, home=1)
|
||||
assert result["state_label"] == ""
|
||||
assert result["home_label"] == ""
|
||||
assert result["away_label"] == ""
|
||||
|
||||
|
||||
def test_missing_raw_matrix_cell_uses_same_settings_default_matrix():
|
||||
result = strength({"strength_state_labels": {}}, home=1)
|
||||
assert result["state_key"] == "5x4"
|
||||
assert result["state_label"] == "PP"
|
||||
assert result["home_label"] == "PP"
|
||||
assert result["away_label"] == "PP"
|
||||
|
||||
|
||||
def test_english_uses_english_caption_from_same_settings_cell():
|
||||
result = strength({
|
||||
"strength_state_labels": {
|
||||
"regulation": {"5x3": {"ru": "ПЯТЬ НА ТРИ", "en": "FIVE ON THREE"}}
|
||||
}
|
||||
}, home=2, language="en")
|
||||
assert result["state_label"] == "FIVE ON THREE"
|
||||
assert result["home_label"] == "FIVE ON THREE"
|
||||
assert result["away_label"] == "FIVE ON THREE"
|
||||
Reference in New Issue
Block a user