Skip to content

Commit ae2664b

Browse files
committed
Fix display tests
1 parent 6e7b3e8 commit ae2664b

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

‎dlclivegui/services/multi_camera_controller.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ def stop(self) -> None:
150150
self._stop_event.set()
151151

152152

153+
def get_display_id(settings: CameraSettings) -> str:
154+
return f"{settings.backend}:{settings.index}"
155+
156+
153157
def get_camera_id(settings: CameraSettings) -> str:
154158
"""Generate a unique camera ID from stable backend identity."""
155159
backend = (settings.backend or "").lower()
@@ -303,7 +307,7 @@ def start(self, camera_settings: list[CameraSettings]) -> None:
303307
def _start_camera(self, settings: CameraSettings) -> None:
304308
"""Start a single camera."""
305309
settings_copy = copy.deepcopy(settings)
306-
cam_id = get_camera_id(settings_copy)
310+
cam_id = get_display_id(settings_copy)
307311
if cam_id in self._workers:
308312
LOGGER.warning(f"Camera {cam_id} already has a worker")
309313
return

‎tests/services/test_multicam_controller.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
_camera_start_priority,
1111
_trigger_role_from_settings,
1212
get_camera_id,
13+
get_display_id,
1314
)
1415

1516

@@ -65,7 +66,7 @@ def test_rotation_and_crop(qtbot, patch_factory):
6566
last_shape = {"shape": None}
6667

6768
def on_ready(mfd):
68-
f = mfd.frames.get(get_camera_id(cam))
69+
f = mfd.frames.get(get_display_id(cam))
6970
if f is not None:
7071
last_shape["shape"] = f.shape
7172

@@ -255,7 +256,7 @@ def test_frame_ready_emits_frames_in_user_configured_order(qtbot, patch_factory)
255256
properties={"opencv": {"device_id": "cam-b"}},
256257
).apply_defaults()
257258

258-
expected_order = [get_camera_id(cam_a), get_camera_id(cam_b)]
259+
expected_order = [get_display_id(cam_a), get_display_id(cam_b)]
259260
seen_orders: list[list[str]] = []
260261

261262
def on_ready(mfd):
@@ -387,7 +388,7 @@ def _create(settings):
387388
mc.start([cam])
388389

389390
cam_id, msg = blocker.args
390-
assert cam_id == get_camera_id(cam)
391+
assert cam_id == get_display_id(cam)
391392
assert "Camera read timeout" in msg
392393

393394
# Cleanup if still running.

0 commit comments

Comments
 (0)