492bdb95e3
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
76 lines
2.6 KiB
Python
76 lines
2.6 KiB
Python
"""Tests for built-in effect presets."""
|
|
|
|
import pytest
|
|
|
|
from wled_controller.core.game_integration.presets import (
|
|
EffectPreset,
|
|
get_all_presets,
|
|
get_preset,
|
|
)
|
|
from wled_controller.storage.game_integration import EventMapping
|
|
|
|
|
|
class TestPresetData:
|
|
"""Verify preset data structure and contents."""
|
|
|
|
def test_get_all_presets_returns_list(self):
|
|
presets = get_all_presets()
|
|
assert isinstance(presets, list)
|
|
assert len(presets) >= 4
|
|
|
|
def test_each_preset_has_required_fields(self):
|
|
for preset in get_all_presets():
|
|
assert isinstance(preset, EffectPreset)
|
|
assert preset.key
|
|
assert preset.name
|
|
assert preset.description
|
|
assert len(preset.target_game_types) > 0
|
|
assert len(preset.event_mappings) > 0
|
|
|
|
def test_each_mapping_is_valid(self):
|
|
for preset in get_all_presets():
|
|
for mapping in preset.event_mappings:
|
|
assert isinstance(mapping, EventMapping)
|
|
assert mapping.event_type
|
|
assert mapping.effect
|
|
assert len(mapping.color) == 3
|
|
assert all(0 <= c <= 255 for c in mapping.color)
|
|
assert mapping.duration_ms > 0
|
|
assert 0.0 <= mapping.intensity <= 1.0
|
|
assert mapping.priority >= 0
|
|
|
|
def test_get_preset_by_key(self):
|
|
assert get_preset("fps_combat") is not None
|
|
assert get_preset("moba_health") is not None
|
|
assert get_preset("racing") is not None
|
|
assert get_preset("generic_alert") is not None
|
|
|
|
def test_get_preset_unknown_returns_none(self):
|
|
assert get_preset("nonexistent") is None
|
|
|
|
def test_fps_combat_has_expected_events(self):
|
|
preset = get_preset("fps_combat")
|
|
assert preset is not None
|
|
event_types = {m.event_type for m in preset.event_mappings}
|
|
assert "health" in event_types
|
|
assert "kill" in event_types
|
|
assert "death" in event_types
|
|
|
|
def test_moba_health_has_expected_events(self):
|
|
preset = get_preset("moba_health")
|
|
assert preset is not None
|
|
event_types = {m.event_type for m in preset.event_mappings}
|
|
assert "health" in event_types
|
|
assert "mana" in event_types
|
|
|
|
def test_presets_are_frozen(self):
|
|
preset = get_preset("fps_combat")
|
|
assert preset is not None
|
|
with pytest.raises(AttributeError):
|
|
preset.name = "Changed" # type: ignore[misc]
|
|
|
|
def test_preset_keys_unique(self):
|
|
presets = get_all_presets()
|
|
keys = [p.key for p in presets]
|
|
assert len(keys) == len(set(keys))
|