Ejemplo n.º 1
0
def test_motor_mutability() -> None:
    """
    Test the mutability of Motors.

    Ensures that Motor objects cannot be lost.
    """
    mb = MotorBoard("SERIAL0", MockMotorBoardBackend())

    with pytest.raises(TypeError):
        mb.motors[1] = 1  # type: ignore
Ejemplo n.º 2
0
def test_motor_board_make_safe() -> None:
    """Test the make_safe method of the motor board."""
    mb = MotorBoard("SERIAL0", MockMotorBoardBackend())

    for m in mb.motors:
        m.power = 1

    mb.make_safe()

    for m in mb.motors:
        assert m.power == MotorSpecialState.BRAKE
Ejemplo n.º 3
0
def test_motor_board_make_safe_option() -> None:
    """Test the default make_safe method of the motor board."""
    TEST_SAFE_STATES: List[MotorState] = [
        MotorSpecialState.BRAKE,
        MotorSpecialState.COAST,
        0,
        0.1,
    ]

    for safe_state in TEST_SAFE_STATES:

        mb = MotorBoard("SERIAL0", MockMotorBoardBackend(), safe_state=safe_state)

        for m in mb.motors:
            m.power = 1

        mb.make_safe()

        for m in mb.motors:
            assert m.power == safe_state
Ejemplo n.º 4
0
def test_motor_board_motors() -> None:
    """Test the motor_outputs on the motor board."""
    mb = MotorBoard("SERIAL0", MockMotorBoardBackend())

    for m in mb.motors:
        assert type(m) is Motor
Ejemplo n.º 5
0
def test_motor_board_serial() -> None:
    """Test the serial attribute of the motor board."""
    mb = MotorBoard("SERIAL0", MockMotorBoardBackend())

    assert mb.serial == "SERIAL0"
Ejemplo n.º 6
0
def test_motor_board_name() -> None:
    """Test the name attribute of the motor board."""
    mb = MotorBoard("SERIAL0", MockMotorBoardBackend())

    assert mb.name == "Student Robotics v4 Motor Board"
Ejemplo n.º 7
0
def test_motor_board_firmware_version() -> None:
    """Test the firmware version on the motor board."""
    mb = MotorBoard("SERIAL0", MockMotorBoardBackend())

    assert mb.firmware_version is None
Ejemplo n.º 8
0
def test_motor_board_instantiation() -> None:
    """Test that we can instantiate a Motor Board."""
    MotorBoard("SERIAL0", MockMotorBoardBackend())
Ejemplo n.º 9
0
def test_motor_board_supported_components() -> None:
    """Test the supported components on the motor board."""
    assert MotorBoard.supported_components() == {Motor}