Files
led-controller/tests/test_update_groups.py
2026-05-28 00:38:21 +12:00

36 lines
972 B
Python

#!/usr/bin/env python3
"""Tests for pushing group membership to all ESP-NOW devices."""
import asyncio
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / "src"))
def test_push_groups_all_espnow_devices(monkeypatch):
from util import espnow_registry
class _Devices:
def items(self):
return [
("aabbccddeeff", {"transport": "espnow"}),
("wifi-1", {"transport": "wifi", "address": "192.168.1.1"}),
]
pushed = []
async def fake_push(mac):
pushed.append(mac)
return True
monkeypatch.setattr(espnow_registry, "Device", _Devices)
monkeypatch.setattr(espnow_registry, "push_groups_to_mac", fake_push)
result = asyncio.run(espnow_registry.push_groups_all_espnow_devices())
assert result["ok"] is True
assert result["sent"] == 1
assert result["total"] == 1
assert pushed == ["aabbccddeeff"]