Exemple #1
0
def test_pin_mutability() -> None:
    """
    Test the mutability of GPIOPins.

    Ensures that GPIOPin objects cannot be lost.
    """
    uno = SBArduinoBoard("SERIAL0", MockSBArduinoBackend())

    with pytest.raises(TypeError):
        uno.pins[2] = True  # type: ignore
Exemple #2
0
def test_uno_ultrasound_sensors() -> None:
    """Test the ultrasound sensors of the arduino."""
    uno = SBArduinoBoard("SERIAL0", MockSBArduinoBackend())
    sensor = uno.ultrasound_sensors[3, 4]
    assert type(sensor) is UltrasoundSensor
    assert sensor._gpio_trigger._identifier == 3
    assert sensor._gpio_echo._identifier == 4
Exemple #3
0
def test_uno_supported_components() -> None:
    """Test that the Uno supports the required components."""
    assert {
        GPIOPin,
        LED,
        UltrasoundSensor,
    }.issubset(SBArduinoBoard.supported_components())
Exemple #4
0
def test_uno_pins() -> None:
    """Test the pins of the Uno."""
    uno = SBArduinoBoard("SERIAL0", MockSBArduinoBackend())

    assert len(uno.pins) == 12 + 6

    for i in range(2, 14):
        assert type(uno.pins[i]) is GPIOPin

    for j in AnaloguePin:
        assert type(uno.pins[j]) is GPIOPin
Exemple #5
0
def test_uno_initialisation() -> None:
    """Test that we can initialise an Uno."""
    SBArduinoBoard("SERIAL0", MockSBArduinoBackend())
Exemple #6
0
def test_uno_make_safe() -> None:
    """Test the make_safe method of the Uno."""
    uno = SBArduinoBoard("SERIAL0", MockSBArduinoBackend())
    uno.make_safe()
Exemple #7
0
def test_uno_firmware_version() -> None:
    """Test the firmware_version attribute of the Uno."""
    uno = SBArduinoBoard("SERIAL0", MockSBArduinoBackend())

    assert uno.firmware_version is None
Exemple #8
0
def test_uno_serial() -> None:
    """Test the serial attribute of the Uno."""
    uno = SBArduinoBoard("SERIAL0", MockSBArduinoBackend())

    assert uno.serial == "SERIAL0"
Exemple #9
0
def test_uno_name() -> None:
    """Test the name attribute of the Uno."""
    uno = SBArduinoBoard("SERIAL0", MockSBArduinoBackend())

    assert uno.name == "Arduino Uno"
Exemple #10
0
 def discover(cls) -> Set[Board]:
     """Discover boards that this backend can control."""
     return {cast(Board, SBArduinoBoard("SERIAL", cls("SERIAL")))}