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
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))
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
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
def test_servo_instantiation(): """Test that we can instantiate a Servo.""" Servo(0, MockServoBoard(), MockServoDriver())
def test_servo_interface_class(): """Test that the interface class is ServoInterface.""" assert Servo.interface_class() is ServoInterface
def test_servo_set_position() -> None: """Test that we can set the position of a servo.""" servo = Servo(2, MockServoDriver()) servo.position = 0.6
def test_servo_identifier() -> None: """Test the identifier attribute of the component.""" component = Servo(0, MockServoDriver()) assert component.identifier == 0
def test_servo_instantiation() -> None: """Test that we can instantiate a Servo.""" Servo(0, MockServoDriver())