Пример #1
0
def test_pin_mutability() -> None:
    """
    Test the mutability of GPIOPins.

    Ensures that GPIOPin objects cannot be lost.
    """
    uno = ArduinoUno("SERIAL0", MockArduinoUnoBackend())

    with pytest.raises(TypeError):
        uno.pins[2] = True  # type: ignore
Пример #2
0
def test_uno_pins() -> None:
    """Test the pins of the Uno."""
    uno = ArduinoUno("SERIAL0", MockArduinoUnoBackend())

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

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

    for j in ArduinoUno.AnaloguePin:
        assert isinstance(uno.pins[j], GPIOPin)
Пример #3
0
def test_uno_serial_number() -> None:
    """Test the serial_number attribute of the Uno."""
    uno = ArduinoUno("SERIAL0", MockArduinoUnoBackend())

    assert uno.serial_number == "SERIAL0"
Пример #4
0
def test_uno_name() -> None:
    """Test the name attribute of the Uno."""
    uno = ArduinoUno("SERIAL0", MockArduinoUnoBackend())

    assert uno.name == "Arduino Uno"
Пример #5
0
def test_uno_initialisation() -> None:
    """Test that we can initialise an Uno."""
    ArduinoUno("SERIAL0", MockArduinoUnoBackend())
Пример #6
0
def test_uno_supported_components() -> None:
    """Test that the Uno supports the required components."""
    assert {
        GPIOPin,
        LED,
    }.issubset(ArduinoUno.supported_components())
Пример #7
0
def test_uno_make_safe() -> None:
    """Test the make_safe method of the Uno."""
    uno = ArduinoUno("SERIAL0", MockArduinoUnoBackend())
    uno.make_safe()
Пример #8
0
def test_uno_firmware_version() -> None:
    """Test the firmware_version attribute of the Uno."""
    uno = ArduinoUno("SERIAL0", MockArduinoUnoBackend())

    assert uno.firmware_version is None