コード例 #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
コード例 #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
コード例 #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
コード例 #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
コード例 #5
0
def test_motor_board_serial() -> None:
    """Test the serial attribute of the motor board."""
    mb = MotorBoard("SERIAL0", MockMotorBoardBackend())

    assert mb.serial == "SERIAL0"
コード例 #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"
コード例 #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
コード例 #8
0
def test_motor_board_instantiation() -> None:
    """Test that we can instantiate a Motor Board."""
    MotorBoard("SERIAL0", MockMotorBoardBackend())
コード例 #9
0
def test_motor_board_supported_components() -> None:
    """Test the supported components on the motor board."""
    assert MotorBoard.supported_components() == {Motor}