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

    Ensures that GPIOPin objects cannot be lost.
    """
    ruggeduino = Ruggeduino("SERIAL0", MockRuggeduinoBackend())

    with pytest.raises(TypeError):
        ruggeduino.pins[2] = True  # type: ignore
Esempio n. 2
0
def test_ruggeduino_supported_components() -> None:
    """Test that the Ruggeduino supports the required components."""
    assert {
        GPIOPin,
        LED,
        StringCommandComponent,
    }.issubset(Ruggeduino.supported_components())
Esempio n. 3
0
def test_ruggeduino_pins() -> None:
    """Test the pins of the Ruggeduino."""
    ruggeduino = Ruggeduino("SERIAL0", MockRuggeduinoBackend())

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

    for i in range(2, 14):
        assert isinstance(ruggeduino.pins[i], GPIOPin)

    for j in Ruggeduino.AnaloguePin:
        assert isinstance(ruggeduino.pins[j], GPIOPin)
Esempio n. 4
0
def test_ruggeduino_name() -> None:
    """Test the name attribute of the Ruggeduino."""
    ruggeduino = Ruggeduino("SERIAL0", MockRuggeduinoBackend())

    assert ruggeduino.name == "Ruggeduino"
Esempio n. 5
0
def test_ruggeduino_initialisation() -> None:
    """Test that we can initialise a Ruggeduino."""
    Ruggeduino("SERIAL0", MockRuggeduinoBackend())
Esempio n. 6
0
def test_ruggeduino_command() -> None:
    """Test that the Ruggeduino has a serial command component."""
    ruggeduino = Ruggeduino("Serial0", MockRuggeduinoBackend())

    assert isinstance(ruggeduino.command, StringCommandComponent)
Esempio n. 7
0
def test_ruggeduino_make_safe() -> None:
    """Test the make_safe method of the Ruggeduino."""
    ruggeduino = Ruggeduino("SERIAL0", MockRuggeduinoBackend())
    ruggeduino.make_safe()
Esempio n. 8
0
def test_ruggeduino_firmware_version() -> None:
    """Test the firmware_version attribute of the Ruggeduino."""
    ruggeduino = Ruggeduino("SERIAL0", MockRuggeduinoBackend())

    assert ruggeduino.firmware_version is None
Esempio n. 9
0
def test_ruggeduino_serial_number() -> None:
    """Test the serial_number attribute of the Ruggeduino."""
    ruggeduino = Ruggeduino("SERIAL0", MockRuggeduinoBackend())

    assert ruggeduino.serial_number == "SERIAL0"