示例#1
0
def test_read_gpio_pin_digital_state() -> None:
    """Test that we can read the digital state of a pin."""
    backend = SBArduinoConsoleBackend(
        "TestBoard",
        console_class=MockConsole,
    )

    backend._pins[10].mode = GPIOPinMode.DIGITAL_INPUT
    backend._console.next_input = "True"  # type: ignore
    assert backend.read_gpio_pin_digital_state(10)
示例#2
0
def test_read_gpio_pin_digital_state_bad_mode() -> None:
    """Test that we cannot read a digital state in the wrong mode."""
    backend = SBArduinoConsoleBackend(
        "TestBoard",
        console_class=MockConsole,
    )

    backend._console.next_input = "True"  # type: ignore

    with pytest.raises(ValueError):
        assert backend.read_gpio_pin_digital_state(10)