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

    assert uno.name == "Arduino Uno"
Exemple #5
0
def test_uno_initialisation() -> None:
    """Test that we can initialise an Uno."""
    ArduinoUno("SERIAL0", MockArduinoUnoBackend())
Exemple #6
0
def test_uno_make_safe() -> None:
    """Test the make_safe method of the Uno."""
    uno = ArduinoUno("SERIAL0", MockArduinoUnoBackend())
    uno.make_safe()
Exemple #7
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