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
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)
def test_uno_serial_number() -> None: """Test the serial_number attribute of the Uno.""" uno = ArduinoUno("SERIAL0", MockArduinoUnoBackend()) assert uno.serial_number == "SERIAL0"
def test_uno_name() -> None: """Test the name attribute of the Uno.""" uno = ArduinoUno("SERIAL0", MockArduinoUnoBackend()) assert uno.name == "Arduino Uno"
def test_uno_initialisation() -> None: """Test that we can initialise an Uno.""" ArduinoUno("SERIAL0", MockArduinoUnoBackend())
def test_uno_supported_components() -> None: """Test that the Uno supports the required components.""" assert { GPIOPin, LED, }.issubset(ArduinoUno.supported_components())
def test_uno_make_safe() -> None: """Test the make_safe method of the Uno.""" uno = ArduinoUno("SERIAL0", MockArduinoUnoBackend()) uno.make_safe()
def test_uno_firmware_version() -> None: """Test the firmware_version attribute of the Uno.""" uno = ArduinoUno("SERIAL0", MockArduinoUnoBackend()) assert uno.firmware_version is None