Exemplo n.º 1
0
def test_power_board_wait_start() -> None:
    """Test the wait_for_start_flash method."""
    pb = PowerBoard("SERIAL0", MockPowerBoardBackend())

    # Note: This isn't a great test, but ensures that the code runs at least.
    pb.wait_for_start_flash()

    assert pb._run_led.state
Exemplo n.º 2
0
def test_output_mutability() -> None:
    """
    Test the mutability of outputs.

    Ensures that Output objects cannot be lost.
    """
    pb = PowerBoard("SERIAL0", MockPowerBoardBackend())

    with pytest.raises(TypeError):
        pb.outputs[PowerOutputPosition.L0] = True  # type: ignore
Exemplo n.º 3
0
def test_power_board_outputs():
    """Test the power outputs on the PowerBoard."""
    pb = PowerBoard("SERIAL0", MockPowerBoardBackend())

    assert type(pb.outputs) is PowerOutputGroup
    assert len(pb.outputs) == 6

    assert type(pb.outputs[PowerOutputPosition.H0])

    for output in pb.outputs:
        assert type(output) is PowerOutput
Exemplo n.º 4
0
def test_power_board_error_led():
    """Test the error LED on the Power Board."""
    pb = PowerBoard("SERIAL0", MockPowerBoardBackend())

    assert type(pb._error_led) is LED
Exemplo n.º 5
0
def test_power_board_battery_sensor():
    """Test the Battery Sensor on the Power Board."""
    pb = PowerBoard("SERIAL0", MockPowerBoardBackend())

    assert type(pb.battery_sensor) is BatterySensor
Exemplo n.º 6
0
def test_power_board_button():
    """Test the Button on the PowerBoard."""
    pb = PowerBoard("SERIAL0", MockPowerBoardBackend())

    assert type(pb.start_button) is Button
Exemplo n.º 7
0
def test_power_board_piezo():
    """Test the Piezo on the PowerBoard."""
    pb = PowerBoard("SERIAL0", MockPowerBoardBackend())

    assert type(pb.piezo) is Piezo
Exemplo n.º 8
0
def test_power_board_make_safe():
    """Test the make_safe method of the PowerBoard."""
    pb = PowerBoard("SERIAL0", MockPowerBoardBackend())
    pb.make_safe()
Exemplo n.º 9
0
def test_power_board_serial():
    """Test the serial attribute of the PowerBoard."""
    pb = PowerBoard("SERIAL0", MockPowerBoardBackend())

    assert pb.serial == "SERIAL0"
Exemplo n.º 10
0
def test_power_board_name():
    """Test the name attribute of the PowerBoard."""
    pb = PowerBoard("SERIAL0", MockPowerBoardBackend())

    assert pb.name == "Student Robotics v4 Power Board"
Exemplo n.º 11
0
def test_power_board_instantiation():
    """Test that we can instantiate a PowerBoard."""
    PowerBoard("SERIAL0", MockPowerBoardBackend())
Exemplo n.º 12
0
def test_power_board_run_led() -> None:
    """Test the run LED on the Power Board."""
    pb = PowerBoard("SERIAL0", MockPowerBoardBackend())

    assert type(pb._run_led) is LED
Exemplo n.º 13
0
def test_firmware_version() -> None:
    """Test the firmware_version attribute of the PowerBoard."""
    pb = PowerBoard("SERIAL0", MockPowerBoardBackend())
    assert pb.firmware_version is None