Skip to content

Commit 6e28c30

Browse files
committed
Update tests: display_id naming and fallback
Adjust tests to reflect new human-friendly display_id values and add a fallback case. Updated expectations in tests to assert display_id equals "GenTL cam" / "GenTL Cam" / "C1" where applicable, and added a unit test to verify get_display_id falls back to the backend index (e.g. "gentl:3") when camera name is empty. Also added assertions in the controller test to ensure the stable camera id is present in frames and correctly mapped to the display id. Files changed: tests/gui/test_rec_manager.py, tests/services/test_multicam_controller.py.
1 parent fa1365b commit 6e28c30

2 files changed

Lines changed: 22 additions & 4 deletions

File tree

tests/gui/test_rec_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ def test_recording_manager_uses_stable_camera_id_not_display_id(
306306
display_id = get_display_id(cam)
307307

308308
assert stable_id == "gentl:serial:SER0"
309-
assert display_id == "gentl:0"
309+
assert display_id == "GenTL cam"
310310
assert stable_id != display_id
311311

312312
frame = np.zeros((480, 640, 3), dtype=np.uint8)

tests/services/test_multicam_controller.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def test_get_display_id_is_human_index_label():
157157
).apply_defaults()
158158

159159
assert get_camera_id(cam) == "gentl:serial:30220469"
160-
assert get_display_id(cam) == "gentl:3"
160+
assert get_display_id(cam) == "GenTL Cam"
161161
assert get_camera_id(cam) != get_display_id(cam)
162162

163163

@@ -193,6 +193,23 @@ def test_trigger_role_from_settings_aliases(role, expected):
193193
assert _trigger_role_from_settings(cam) == expected
194194

195195

196+
@pytest.mark.unit
197+
def test_get_display_id_falls_back_to_backend_index_without_name():
198+
cam = CameraSettings(
199+
name="",
200+
backend="gentl",
201+
index=3,
202+
properties={
203+
"gentl": {
204+
"device_id": "serial:30220469",
205+
"serial_number": "30220469",
206+
}
207+
},
208+
).apply_defaults()
209+
210+
assert get_display_id(cam) == "gentl:3"
211+
212+
196213
@pytest.mark.unit
197214
def test_camera_start_priority_orders_trigger_roles():
198215
external = CameraSettings(
@@ -330,9 +347,8 @@ def test_controller_uses_stable_camera_id_not_display_id(qtbot, patch_factory):
330347
display_id = get_display_id(cam)
331348

332349
assert stable_id == "gentl:serial:SER0"
333-
assert display_id == "gentl:0"
350+
assert display_id == "C1"
334351
assert stable_id != display_id
335-
336352
seen = []
337353

338354
def on_ready(mfd):
@@ -348,6 +364,8 @@ def on_ready(mfd):
348364

349365
mfd = seen[-1]
350366

367+
assert stable_id in mfd.frames
368+
assert mfd.display_ids[stable_id] == "C1"
351369
assert mfd.source_camera_id == stable_id
352370
assert stable_id in mfd.frames
353371
assert stable_id in mfd.timestamps

0 commit comments

Comments
 (0)