feat: add pluggable alarm styles and migrate wecker.py
Introduce a styles/ plugin package: - styles/base.py: AlarmStyle ABC (injected set_led, update()->bool contract) - styles/blink.py: BlinkStyle, the existing count-the-blinks puzzle moved out of wecker.py's AlarmClock - styles/simple.py: SimpleStyle, press-once-to-stop (the new default style) - styles/__init__.py: STYLES registry + get_style() validator + LEGACY_STYLE wecker.py now resolves the style via the registry and owns only the shared music/button/cleanup loop; the --style CLI arg defaults to blink so existing cron entries keep their behaviour. Unknown styles raise before hardware init.
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import pytest
|
||||
|
||||
from styles import STYLES, get_style
|
||||
from styles.blink import BlinkStyle
|
||||
from styles.simple import SimpleStyle
|
||||
|
||||
|
||||
def test_registry_has_blink_and_simple():
|
||||
assert STYLES["blink"] is BlinkStyle
|
||||
assert STYLES["simple"] is SimpleStyle
|
||||
|
||||
|
||||
def test_get_style_returns_class():
|
||||
assert get_style("blink") is BlinkStyle
|
||||
assert get_style("simple") is SimpleStyle
|
||||
|
||||
|
||||
def test_get_style_unknown_raises():
|
||||
with pytest.raises(ValueError, match="Unknown alarm style"):
|
||||
get_style("nope")
|
||||
Reference in New Issue
Block a user