from tests.timer_contract_support import run_timer_contract, assert_current_build_contract from datetime import datetime from pathlib import Path from zoneinfo import ZoneInfo from ui_builder.auth import EditorAuthManager 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") AUTH = (ROOT / "ui_builder/auth.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_vmix_queue_resolves_countdown_values_at_actual_send_time(): from tests.test_build103_space_timer_fast_transport import run_transport_contract run_transport_contract("queued_values_sampled_at_dispatch") def test_countdown_start_is_simple_set_start(): """Current native timer contract, executed against production functions.""" run_timer_contract('first_start') def test_pause_and_stop_freeze_without_reseed(): """Current native timer contract, executed against production functions.""" run_timer_contract('pause_freezes') # Native penalty transitions are exercised in test_stage2_penalty_countdown.py. def test_running_penalty_is_preferred_over_paused_shorter_penalty(): """Current native timer contract, executed against production functions.""" run_timer_contract('penalty_priority') def test_fixed_pin_1993_replaces_daily_login(tmp_path, monkeypatch): monkeypatch.delenv("EDITOR_FIXED_PIN", raising=False) auth = EditorAuthManager(tmp_path) assert auth.settings["fixed_pin"] == "1993" # The old daily algorithm remains diagnostic-only; for 24.08.2026 its # default result is 6225, but login validation no longer uses it. assert auth.daily_pin(datetime(2026, 8, 24, 12, 0, tzinfo=ZoneInfo("Europe/Moscow"))) == "6225" assert 'valid = hmac.compare_digest(supplied, str(self.settings["fixed_pin"]))' in AUTH def test_build98_runtime_version(): assert_current_build_contract()