refactor: keep style-specific config off the base class via **kwargs
The base AlarmStyle contract carried music_file, forcing SimpleStyle to accept a parameter it never uses. Move style-specific config to the subclass: the base __init__ takes only set_led (**kwargs swallows the rest); each style declares the keyword args it actually uses (BlinkStyle: music_file; SimpleStyle: none). The runner passes config as keyword args and each style keeps only what it needs, so the base contract never grows as styles are added — a future 'talk' style adds talk_file to its own signature, not to the base. README plugin contract updated.
This commit is contained in:
@@ -8,6 +8,16 @@ def _make_style():
|
||||
return SimpleStyle(lambda on: calls.append(on)), calls
|
||||
|
||||
|
||||
def test_simple_ignores_unrelated_config():
|
||||
# SimpleStyle must swallow style-specific kwargs it doesn't use (e.g.
|
||||
# music_file belongs to blink), so the runner can pass config uniformly.
|
||||
style, _ = _make_style()
|
||||
style = SimpleStyle(lambda on: None, music_file="ignored.mp3")
|
||||
with patch("styles.simple.pygame", MagicMock()):
|
||||
style.start()
|
||||
assert style.update(0.0, False) is True
|
||||
|
||||
|
||||
def test_simple_keeps_ringing_when_not_pressed():
|
||||
style, _ = _make_style()
|
||||
with patch("styles.simple.pygame", MagicMock()):
|
||||
|
||||
Reference in New Issue
Block a user