diff --git a/src/lerobot/cameras/reachy2_camera/configuration_reachy2_camera.py b/src/lerobot/cameras/reachy2_camera/configuration_reachy2_camera.py index 214ff9195..5b2303ff2 100644 --- a/src/lerobot/cameras/reachy2_camera/configuration_reachy2_camera.py +++ b/src/lerobot/cameras/reachy2_camera/configuration_reachy2_camera.py @@ -65,10 +65,8 @@ class Reachy2CameraConfig(CameraConfig): def __post_init__(self): if self.name not in ["teleop", "depth"]: raise ValueError(f"`name` is expected to be 'teleop' or 'depth', but {self.name} is provided.") - if ( - (self.name == "teleop" and self.image_type not in ["left", "right"]) - or (self.name == "depth") - and self.image_type not in ["rgb", "depth"] + if (self.name == "teleop" and self.image_type not in ["left", "right"]) or ( + self.name == "depth" and self.image_type not in ["rgb", "depth"] ): raise ValueError( f"`image_type` is expected to be 'left' or 'right' for teleop camera, and 'rgb' or 'depth' for depth camera, but {self.image_type} is provided." diff --git a/tests/cameras/test_reachy2_camera.py b/tests/cameras/test_reachy2_camera.py index 79f811f66..66c7675a6 100644 --- a/tests/cameras/test_reachy2_camera.py +++ b/tests/cameras/test_reachy2_camera.py @@ -158,3 +158,20 @@ def test_disconnect_before_connect(camera): def test_async_read_before_connect(camera): with pytest.raises(DeviceNotConnectedError): _ = camera.async_read() + + +def test_wrong_camera_name(): + with pytest.raises(ValueError): + _ = Reachy2CameraConfig(name="wrong-name", image_type="left") + + +def test_wrong_image_type(): + with pytest.raises(ValueError): + _ = Reachy2CameraConfig(name="teleop", image_type="rgb") + with pytest.raises(ValueError): + _ = Reachy2CameraConfig(name="depth", image_type="left") + + +def test_wrong_color_mode(): + with pytest.raises(ValueError): + _ = Reachy2CameraConfig(name="teleop", image_type="left", color_mode="wrong-color")