예제 #1
0
def test_servo_set_position_out_of_bounds():
    """Test that we cannot set < -1 or > 1."""
    servo = Servo(2, MockServoBoard(), MockServoDriver())

    with pytest.raises(ValueError):
        servo.position = 2

    with pytest.raises(ValueError):
        servo.position = -2
예제 #2
0
    def __init__(self, serial: str, backend: Backend):
        self._serial = serial
        self._backend = backend

        self._servos = ImmutableList[Servo](
            Servo(servo, cast(ServoInterface, self._backend))
            for servo in range(0, 12))
예제 #3
0
def test_servo_set_position_none():
    """Test that we can set the position of a servo to None."""
    servo = Servo(2, MockServoBoard(), MockServoDriver())
    servo.position = None
예제 #4
0
def test_servo_get_position():
    """Test that we can get the position of a servo."""
    servo = Servo(2, MockServoBoard(), MockServoDriver())
    assert type(servo.position) is float
    assert servo.position == 0.5
예제 #5
0
def test_servo_instantiation():
    """Test that we can instantiate a Servo."""
    Servo(0, MockServoBoard(), MockServoDriver())
예제 #6
0
def test_servo_interface_class():
    """Test that the interface class is ServoInterface."""
    assert Servo.interface_class() is ServoInterface
예제 #7
0
def test_servo_set_position() -> None:
    """Test that we can set the position of a servo."""
    servo = Servo(2, MockServoDriver())
    servo.position = 0.6
예제 #8
0
def test_servo_identifier() -> None:
    """Test the identifier attribute of the component."""
    component = Servo(0, MockServoDriver())
    assert component.identifier == 0
예제 #9
0
def test_servo_instantiation() -> None:
    """Test that we can instantiate a Servo."""
    Servo(0, MockServoDriver())