Files
ledgrab/server/tests/core/test_game_wiring.py
T
alexei.dolgolyov 492bdb95e3 feat: game integration system
Receive real-time events from games (CS2, Dota 2, LoL, etc.) and drive
LED effects through the existing color strip and value source pipelines.

Core:
- GameEventBus (thread-safe pub/sub) with standardized 23-type event vocabulary
- GameAdapter ABC + AdapterRegistry + MappingAdapter (YAML-driven)
- Built-in adapters: CS2 GSI, Dota 2 GSI, LoL Live Client, Generic Webhook
- Community YAML adapters: Minecraft, Valorant, Rocket League
- GameEventColorStripStream with 5 effects (flash/pulse/sweep/color_shift/breathing)
- GameEventValueSource with EMA smoothing and timeout
- 4 built-in effect presets (FPS Combat, MOBA Health, Racing, Generic Alert)
- Auto-setup for Valve GSI games (Steam path detection, cfg file writing)
- Demo capture engine exposed to non-demo mode

Frontend:
- Game tab in Streams tree navigation with integration cards
- Game integration editor modal with adapter picker, config fields, event mappings
- game_event source type in CSS and ValueSource editors
- Setup instructions overlay (markdown rendered)
- Live event monitor and connection test

API:
- Full CRUD for game integrations
- Event ingestion endpoint (adapter-level auth)
- Adapter metadata, presets, auto-setup, status/diagnostics endpoints
2026-03-31 13:17:52 +03:00

48 lines
1.6 KiB
Python

"""Tests verifying game integration wiring in ProcessorDependencies.
Ensures that GameEventBus is properly threaded through to
ColorStripStreamManager and ValueStreamManager.
"""
from wled_controller.core.game_integration.event_bus import GameEventBus
from wled_controller.core.processing.processor_manager import (
ProcessorDependencies,
ProcessorManager,
)
class TestGameEventBusWiring:
"""Verify that game_event_bus propagates through ProcessorManager."""
def test_processor_dependencies_accepts_game_event_bus(self):
bus = GameEventBus()
deps = ProcessorDependencies(game_event_bus=bus)
assert deps.game_event_bus is bus
def test_css_stream_manager_receives_bus(self):
bus = GameEventBus()
deps = ProcessorDependencies(game_event_bus=bus)
pm = ProcessorManager(deps)
css_mgr = pm._color_strip_stream_manager
assert css_mgr._game_event_bus is bus
def test_value_stream_manager_receives_bus(self):
"""ValueStreamManager is only created when value_source_store is provided."""
from unittest.mock import MagicMock
bus = GameEventBus()
mock_vs_store = MagicMock()
deps = ProcessorDependencies(
game_event_bus=bus,
value_source_store=mock_vs_store,
)
pm = ProcessorManager(deps)
vs_mgr = pm._value_stream_manager
assert vs_mgr is not None
assert vs_mgr._event_bus is bus
def test_without_bus_defaults_to_none(self):
deps = ProcessorDependencies()
pm = ProcessorManager(deps)
assert pm._color_strip_stream_manager._game_event_bus is None