Esempio n. 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
Esempio n. 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)
Esempio n. 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"
Esempio n. 4
0
def test_uno_name() -> None:
    """Test the name attribute of the Uno."""
    uno = ArduinoUno("SERIAL0", MockArduinoUnoBackend())

    assert uno.name == "Arduino Uno"
Esempio n. 5
0
def test_uno_initialisation() -> None:
    """Test that we can initialise an Uno."""
    ArduinoUno("SERIAL0", MockArduinoUnoBackend())
Esempio n. 6
0
def test_uno_supported_components() -> None:
    """Test that the Uno supports the required components."""
    assert {
        GPIOPin,
        LED,
    }.issubset(ArduinoUno.supported_components())
Esempio n. 7
0
def test_uno_make_safe() -> None:
    """Test the make_safe method of the Uno."""
    uno = ArduinoUno("SERIAL0", MockArduinoUnoBackend())
    uno.make_safe()
Esempio n. 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