예제 #1
0
def test_analog_read_can_only_be_done_by_registered_component(
    test_arduino: Arduino, ) -> None:
    test_arduino.analog_read(1)

    test_arduino.register_component("component_id_1", pins=(Pin(1), ))

    test_arduino.analog_read(1, token="component_id_1")
    with pytest.raises(ProtectedPinError):
        test_arduino.analog_read(1)
    with pytest.raises(ProtectedPinError):
        test_arduino.analog_read(1, token="component_id_2")
예제 #2
0
def test_analog_read_with_reserved_pin(test_arduino: Arduino) -> None:
    with pytest.raises(PinIsReservedForSerialCommsError):
        test_arduino.analog_read(4)
예제 #3
0
def test_analog_read_with_non_analog_pin(test_arduino: Arduino) -> None:
    with pytest.raises(NotAnalogPinError):
        test_arduino.analog_read(0)
예제 #4
0
def test_analog_read_with_pin_no_out_of_range(test_arduino: Arduino) -> None:
    with pytest.raises(PinDoesNotExistError):
        test_arduino.analog_read(6)
예제 #5
0
def test_analog_read_with_valid_args(test_arduino: Arduino) -> None:
    state = test_arduino.analog_read(1)
    assert state == 100