示例#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
示例#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
示例#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
示例#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
示例#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
示例#6
0
def test_power_board_button():
    """Test the Button on the PowerBoard."""
    pb = PowerBoard("SERIAL0", MockPowerBoardBackend())

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

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

    assert pb.serial == "SERIAL0"
示例#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"
示例#11
0
def test_power_board_instantiation():
    """Test that we can instantiate a PowerBoard."""
    PowerBoard("SERIAL0", MockPowerBoardBackend())
示例#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
示例#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