예제 #1
0
def test_digital_write_can_only_be_done_by_registered_component(
    test_arduino: Arduino, ) -> None:
    test_arduino.digital_write(0, HIGH)

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

    test_arduino.digital_write(0, HIGH, token="component_id_1")
    with pytest.raises(ProtectedPinError):
        test_arduino.digital_write(0, HIGH)
    with pytest.raises(ProtectedPinError):
        test_arduino.digital_write(0, HIGH, token="component_id_2")
예제 #2
0
def test_serial_comms_pins_cannot_be_used(arduino: Arduino) -> None:
    with pytest.raises(PinIsReservedForSerialCommsError):
        arduino.digital_write(0, HIGH)
    with pytest.raises(PinIsReservedForSerialCommsError):
        arduino.digital_write(1, HIGH)
예제 #3
0
def test_digital_write_with_reserved_pin(test_arduino: Arduino) -> None:
    with pytest.raises(PinIsReservedForSerialCommsError):
        test_arduino.digital_write(4, HIGH)
예제 #4
0
def test_digital_write_with_pin_no_out_of_range(test_arduino: Arduino) -> None:
    with pytest.raises(PinDoesNotExistError):
        test_arduino.digital_write(6, HIGH)
예제 #5
0
def test_digital_write_with_incorrect_state(test_arduino: Arduino) -> None:
    with pytest.raises(ValueError):
        test_arduino.digital_write(0, INPUT)  # type: ignore
예제 #6
0
def test_digital_write_with_valid_args(test_arduino: Arduino) -> None:
    test_arduino.digital_write(0, HIGH)