"""Sequence rows with U/V, the buttons that act on them, and the tab order.""" from __future__ import annotations from orisys_app_shared.i18n import t def test_the_geometry_tab_comes_before_the_sequence_tab(make_window): window = make_window() assert window.workspace.page_keys() == ["axes", "finger", "sequence", "sensor", "records"] window.close() def test_the_point_table_shows_u_and_v(make_window): window = make_window() panel = window.sequence_panel keys = panel.column_keys() assert keys.index("u") == keys.index("z") + 1 and keys.index("v") == keys.index("u") + 1 row = panel.append_point(1.0, 2.0, 3.0, uv=(-130.0, 470.0)) cells = panel.point_row(row) assert (cells["u"], cells["v"]) == ("-130.0", "470.0") # The placeholder rows have none, and say so. assert panel.point_row(0)["u"] == "—" assert panel.uv_of_row(0) is None assert panel.uv_of_row(row) == (-130.0, 470.0) window.close() def test_send_is_off_until_a_row_with_uv_is_selected(make_window): window = make_window() panel = window.sequence_panel row = panel.append_point(1.0, 2.0, 3.0, uv=(10.0, 20.0)) assert not panel.send_button.isEnabled() panel.table.selectRow(0) # a placeholder without U/V assert not panel.send_button.isEnabled() panel.table.selectRow(row) assert panel.send_button.isEnabled() assert panel.send_button.text() == t("sequence.btn_send", count=1) window.close() def test_sending_emits_the_selected_uv_and_removing_renumbers(make_window): window = make_window() panel = window.sequence_panel first = panel.append_point(1.0, 0.0, 0.0, uv=(10.0, 20.0)) second = panel.append_point(2.0, 0.0, 0.0, uv=(30.0, 40.0)) sent: list = [] panel.sendToCaptureRequested.connect(sent.append) panel.table.selectRow(second) panel.send_button.click() assert sent == [[(30.0, 40.0)]] panel.table.selectRow(first) assert panel.remove_selected() == 1 assert panel.point_row(panel.point_row_count() - 1)["index"] == str(panel.point_row_count()) window.close() def test_a_picked_point_is_added_once_with_its_uv(make_window): window = make_window() panel = window.sequence_panel window.finger_panel._point = { # noqa: SLF001 - stands in for a click on a real surface "X": 1.5, "Y": 2.5, "Z": 12.4, "u_px": -130.0, "v_px": 470.0, } before = panel.point_row_count() window._on_add_picked_to_sequence() # noqa: SLF001 window._on_add_picked_to_sequence() # noqa: SLF001 - the same point again assert panel.point_row_count() == before + 1 assert panel.uv_of_row(before) == (-130.0, 470.0) window.close() def test_sending_to_capture_queues_the_points_and_opens_that_page(make_window, monkeypatch): window = make_window() calls: list = [] monkeypatch.setattr( window.calibration_panel, "add_uv_points", lambda uvs: calls.append(uvs) or (len(uvs), 0) ) window.workspace.set_current_key("sequence") window._on_send_sequence_to_capture([(1.0, 2.0)]) # noqa: SLF001 assert calls == [[(1.0, 2.0)]] assert window.workspace.current_key() == "sensor" window.close() def test_a_pick_reports_in_the_picker_not_in_the_global_strip(make_window): window = make_window() strip_before = window.status_strip.last_action_text() if hasattr( window.status_strip, "last_action_text" ) else None window._on_pick_point(1, 1) # noqa: SLF001 - no bundle: the picker says why assert window.finger_panel.status_label.text() == t("finger.no_bundle") if strip_before is not None: assert window.status_strip.last_action_text() == strip_before window.close()