Implement GPIO button hold detection and LED feedback (story 4-1)
Replace stub ButtonHoldDetector and LEDController with real gpiozero implementations; update tests to use MockFactory so they run without physical GPIO hardware. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,12 +1,26 @@
|
||||
import pytest
|
||||
from gpiozero import Device
|
||||
from gpiozero.pins.mock import MockFactory
|
||||
|
||||
from planemapper.gpio_ctrl import ButtonHoldDetector, LEDController
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def mock_gpio() -> None:
|
||||
Device.pin_factory = MockFactory()
|
||||
|
||||
|
||||
def test_button_hold_detector_returns_bool() -> None:
|
||||
detector = ButtonHoldDetector()
|
||||
result = detector.check()
|
||||
assert isinstance(result, bool)
|
||||
|
||||
|
||||
def test_button_hold_detector_not_held_by_default() -> None:
|
||||
detector = ButtonHoldDetector()
|
||||
assert detector.check() is False
|
||||
|
||||
|
||||
def test_led_controller_on_off_no_exception() -> None:
|
||||
led = LEDController()
|
||||
led.on()
|
||||
|
||||
Reference in New Issue
Block a user