тест 2
This commit is contained in:
@@ -22,7 +22,8 @@ def test_timer_start_stop_protocol_is_minimal():
|
||||
helper = _block("function vmixCountdownSyncCommands", "function buildShortcutRuntimeContext")
|
||||
assert 'if (action === "stop" || action === "pause")' in helper
|
||||
stop_branch = helper.split('if (action === "stop" || action === "pause")', 1)[1].split('return [', 1)[1].split('];', 1)[0]
|
||||
assert stop_branch.index('Function: "StopCountdown"') < stop_branch.index('Function: "SetCountdown"')
|
||||
assert 'Function: "StopCountdown"' in stop_branch
|
||||
assert 'Function: "SetCountdown"' not in stop_branch
|
||||
start_branch = helper.rsplit('return [', 1)[1]
|
||||
assert start_branch.index('Function: "SetCountdown"') < start_branch.index('Function: "StartCountdown"')
|
||||
assert 'SuspendCountdown' not in helper
|
||||
|
||||
@@ -89,7 +89,6 @@ def test_timer_fast_backend_uses_one_no_ack_batch_and_bypasses_mapping_lock(tmp_
|
||||
user,
|
||||
[
|
||||
{"Function": "StopCountdown", "Input": "SCORE", "SelectedName": "TIME.Text"},
|
||||
{"Function": "SetCountdown", "Input": "SCORE", "SelectedName": "TIME.Text", "Value": "00:18:41"},
|
||||
],
|
||||
delivery_mode="timer-fast",
|
||||
),
|
||||
@@ -97,16 +96,21 @@ def test_timer_fast_backend_uses_one_no_ack_batch_and_bypasses_mapping_lock(tmp_
|
||||
)
|
||||
|
||||
batches = [item for item in ws.sent if item.get("type") == "vmix.batch"]
|
||||
assert len(batches) == 2
|
||||
singles = [item for item in ws.sent if item.get("type") == "vmix.command"]
|
||||
assert len(batches) == 1
|
||||
assert [item["Function"] for item in batches[0]["commands"]] == ["SetCountdown", "StartCountdown"]
|
||||
assert [item["Function"] for item in batches[1]["commands"]] == ["StopCountdown", "SetCountdown"]
|
||||
assert not [item for item in ws.sent if item.get("type") == "vmix.command"]
|
||||
for payload in (result, stop_result):
|
||||
assert payload["ok"] is True
|
||||
assert payload["transport"] == "timer-batch-no-ack"
|
||||
assert payload["confirmation"] == "not_waited"
|
||||
assert payload["applied"] == 2
|
||||
assert all(row["ack_waited"] is False for row in payload["results"])
|
||||
assert len(singles) == 1
|
||||
assert singles[0]["command"]["Function"] == "StopCountdown"
|
||||
assert result["ok"] is True
|
||||
assert result["transport"] == "timer-batch-no-ack"
|
||||
assert result["confirmation"] == "not_waited"
|
||||
assert result["applied"] == 2
|
||||
assert all(row["ack_waited"] is False for row in result["results"])
|
||||
assert stop_result["ok"] is True
|
||||
assert stop_result["transport"] == "timer-no-ack"
|
||||
assert stop_result["confirmation"] == "not_waited"
|
||||
assert stop_result["applied"] == 1
|
||||
assert all(row["ack_waited"] is False for row in stop_result["results"])
|
||||
assert not hub._pending_commands
|
||||
|
||||
asyncio.run(scenario())
|
||||
|
||||
37
tests/test_build104_timer_stop_no_rollback.py
Normal file
37
tests/test_build104_timer_stop_no_rollback.py
Normal file
@@ -0,0 +1,37 @@
|
||||
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 _block(start: str, end: str) -> str:
|
||||
return APP_JS.split(start, 1)[1].split(end, 1)[0]
|
||||
|
||||
|
||||
def test_pause_stop_sends_only_stopcountdown():
|
||||
helper = _block("function vmixCountdownSyncCommands", "function buildShortcutRuntimeContext")
|
||||
branch = helper.split('if (action === "stop" || action === "pause")', 1)[1].split('if (action === "set")', 1)[0]
|
||||
assert 'Function: "StopCountdown"' in branch
|
||||
assert 'Function: "SetCountdown"' not in branch
|
||||
|
||||
|
||||
def test_explicit_edit_still_can_seed_stopped_clock():
|
||||
helper = _block("function vmixCountdownSyncCommands", "function buildShortcutRuntimeContext")
|
||||
branch = helper.split('if (action === "set")', 1)[1].split('return [', 2)[1]
|
||||
assert 'Function: "StopCountdown"' in branch
|
||||
assert 'Function: "SetCountdown"' in branch
|
||||
sync = _block("async function syncActiveVmixGameCountdown", "function penaltyMirrorKey")
|
||||
assert 'timerState.running ? "start" : "set"' in sync
|
||||
|
||||
|
||||
def test_penalty_pause_preserves_native_vmix_frozen_value():
|
||||
rebalance = _block("async function rebalanceVmixPenaltyTargets", "function finishActionMatchesSource")
|
||||
assert "preservePausedCountdown = false" in rebalance
|
||||
assert "if (!preservePausedCountdown || assignmentChanged)" in rebalance
|
||||
control = _block("function controlHockeyPenalty", "function formatHockeyPenaltyTime")
|
||||
assert 'preservePausedCountdown: command === "pause"' in control
|
||||
|
||||
|
||||
def test_build104_runtime_version():
|
||||
assert 'BUILD_VERSION = "2026.08.24.7"' in APP
|
||||
@@ -30,12 +30,11 @@ def test_countdown_start_is_simple_set_start():
|
||||
assert 'Value: currentValue' in helper
|
||||
|
||||
|
||||
def test_pause_and_stop_use_stop_then_set():
|
||||
def test_pause_and_stop_freeze_without_reseed():
|
||||
helper = _block("function vmixCountdownSyncCommands", "function buildShortcutRuntimeContext")
|
||||
branch = helper.split('if (action === "stop" || action === "pause")', 1)[1].split('return [', 1)[1].split('];', 1)[0]
|
||||
assert 'Function: "StopCountdown"' in branch
|
||||
assert 'Function: "SetCountdown"' in branch
|
||||
assert branch.index('Function: "StopCountdown"') < branch.index('Function: "SetCountdown"')
|
||||
assert 'Function: "SetCountdown"' not in branch
|
||||
assert 'Function: "SuspendCountdown"' not in branch
|
||||
assert 'Function: "PauseCountdown"' not in branch
|
||||
|
||||
|
||||
Reference in New Issue
Block a user