Add cameras tests

This commit is contained in:
glannuzel
2025-08-28 15:33:56 +02:00
parent f31acfd67f
commit 8e8ebe3732
2 changed files with 19 additions and 4 deletions
@@ -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."
+17
View File
@@ -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")