Files
LEDMatrix/test/test_vegas_coordinator_config.py
T
ChuckandClaude Opus 5.5 7e066174d9 chore: remove dead code, deprecate unused plugin APIs (over-engineering audit)
Whole-tree audit. Every symbol was checked against core, the plugin
monorepo and all eight third-party plugins in plugins.json first.

- Deprecate (removal 3.10.0) plugin-facing methods nothing calls:
  LogoDownloader bulk download, ConfigManager backup/secret wrappers,
  APIHelper extras, BackgroundDataService poll API, PluginManager /
  PluginStateManager info readers, and a few CacheManager, FontManager,
  BaseOddsManager, DynamicTeamResolver methods and PluginTestCase.
  plugin_api_usage.py learns their receiver names; DEPRECATIONS doc
  regenerated.
- Remove core-internal dead code: CacheMetrics, Vegas status/stats
  plumbing, sync "new cycle" message (followers ignore unknown types),
  unused operation types, test-only PluginCatalog readers, IPC to_dict
  and ping, _parse_form_value, CacheStrategyProtocol, ErrorAggregator
  callbacks, duplicate web response helpers.
- Web UI: drop never-mounted json-file-manager.js, the example widget,
  utils/error_handler.js, four uncalled PluginAPI methods, and 29
  escapeHtml shims (call window.LEDEscape directly). Public globals,
  BaseWidget and widget names unchanged.
- Remove six one-off scripts (owner decision) and the unused markupsafe
  and pytest-mock pins.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 18:27:40 -04:00

96 lines
3.7 KiB
Python

"""VegasModeCoordinator: settings updates and the per-frame live check.
- Settings saved in the web UI are queued with update_config() and applied
between frames. run_frame() returns early once Vegas has stopped, so a
disable followed by a re-enable used to be queued forever.
- The live-priority scan asks every plugin mode whether it is live. It ran on
every frame (125fps); it now runs at most every _LIVE_PRIORITY_CHECK_INTERVAL.
"""
import threading
from unittest.mock import MagicMock
from src.vegas_mode import coordinator as coordinator_module
from src.vegas_mode.config import VegasModeConfig
from src.vegas_mode.coordinator import VegasModeCoordinator
def _coordinator(active=True):
# Built without __init__ so no display, stream or render stack is needed.
c = VegasModeCoordinator.__new__(VegasModeCoordinator)
c.vegas_config = VegasModeConfig.from_config({'display': {'vegas_scroll': {'enabled': True}}})
c.render_pipeline = MagicMock()
c.render_pipeline.has_deferred.return_value = False
c.render_pipeline.needs_extension.return_value = False
c.render_pipeline.is_cycle_complete.return_value = False
c.stream_manager = MagicMock()
c.plugin_adapter = MagicMock()
c._state_lock = threading.Lock()
c._is_active = active
c._is_paused = False
c._should_stop = False
c._pending_config_update = False
c._pending_config = None
c._config_version = 0
c._live_priority_check = None
c._live_priority_active = False
c._interrupt_check = None
c.sync_manager = None
return c
class TestConfigWhileStopped:
def test_queued_config_applies_while_stopped(self):
c = _coordinator(active=False)
c.update_config({'display': {'vegas_scroll': {'enabled': True, 'scroll_speed': 90}}})
c.start = MagicMock()
c.apply_pending_config_if_idle()
assert c.vegas_config.scroll_speed == 90
assert c._pending_config_update is False
def test_reenabling_after_a_disable_takes_effect(self):
c = _coordinator(active=False)
c.vegas_config = VegasModeConfig.from_config({}) # disabled
c.start = MagicMock()
c.update_config({'display': {'vegas_scroll': {'enabled': True}}})
c.apply_pending_config_if_idle()
assert c.is_enabled
c.start.assert_called_once()
def test_running_coordinator_waits_for_the_next_frame(self):
c = _coordinator(active=True)
c.update_config({'display': {'vegas_scroll': {'enabled': True, 'scroll_speed': 90}}})
c.apply_pending_config_if_idle()
assert c.vegas_config.scroll_speed != 90
assert c._pending_config_update is True
class TestLivePriorityThrottle:
"""The full-screen takeover's live scan: live_in_ticker off, no longer the default."""
def test_scan_runs_at_most_once_per_interval(self, monkeypatch):
now = [1000.0]
monkeypatch.setattr(coordinator_module.time, 'monotonic', lambda: now[0])
c = _coordinator()
c.vegas_config.live_in_ticker = False
c._live_priority_check = MagicMock(return_value=None)
for _ in range(10):
c.run_frame()
assert c._live_priority_check.call_count == 1
now[0] += coordinator_module._LIVE_PRIORITY_CHECK_INTERVAL
c.run_frame()
assert c._live_priority_check.call_count == 2
def test_live_content_still_pauses_vegas(self, monkeypatch):
monkeypatch.setattr(coordinator_module.time, 'monotonic', lambda: 1000.0)
c = _coordinator()
c.vegas_config.live_in_ticker = False
c._live_priority_check = MagicMock(return_value='nfl_live')
c.pause = MagicMock()
assert c.run_frame() is False
c.pause.assert_called_once()
c.render_pipeline.render_frame.assert_not_called()