test_force_operations ===================== .. py:module:: test_force_operations .. autoapi-nested-parse:: Tests for force operations functionality in user interactions. This module tests the force option dialog and the force parameter behavior when performing operations like adding nodes and edges that would normally fail due to conflicts. Classes ------- .. autoapisummary:: test_force_operations.MockEvent Functions --------- .. autoapisummary:: test_force_operations.create_event_val test_force_operations.test_confirm_force_operation_all_buttons test_force_operations.test_on_paint_invalid_action_upstream_division1_forceable test_force_operations.test_on_paint_invalid_action_upstream_division2_forceable test_force_operations.test_invalid_edge_force Module Contents --------------- .. py:class:: MockEvent(value) .. py:attribute:: value .. py:function:: create_event_val(tp: int, z: tuple[int], y: tuple[int], x: tuple[int], old_val: int, target_val: int) -> list[tuple[tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray], numpy.ndarray, int]] Create event values to simulate a paint event .. py:function:: test_confirm_force_operation_all_buttons(qtbot, monkeypatch, button_index, expected) Test confirm_force_operation for each button and print which was clicked. .. py:function:: test_on_paint_invalid_action_upstream_division1_forceable(make_napari_viewer, graph_3d, segmentation_3d, monkeypatch, confirm_response, expect_force_retry) Test paint event processing 1) Paint with a the track_id (3) of node 4, at the time point of node 2. This is technically invalid, because node 2 has already divided upstream. Therefore, the force dialog should pop up. 2) (Control) Setting tracks_viewer.selected_track to None should allow painting with a new track_id, therefore, no InvalidActionError should be raised, and no dialog should be triggered. TP 0 1 1 Control: 1 1 | | | | 1 2 -1-> 2 5 2 -2-> 2 5 / \ (force) / | / \ / 2 3 4 3 4 3 4 3 4 .. py:function:: test_on_paint_invalid_action_upstream_division2_forceable(make_napari_viewer, graph_3d, segmentation_3d, monkeypatch, confirm_response, expect_force_retry) Test paint event processing 1) Paint with the track_id of node 2 at time point 2. This is invalid, because node 2 has already divided at time point 1. 2) (Control) Setting tracks_viewer.selected_track to None should allow painting with a new track_id. 0 1 1 Control: 1 1 | | | | 1 2 -1-> 2 2 -2-> 2 / \ (force) | / \ / 2 3 4 3 5 4 3 4 3 4 5 .. py:function:: test_invalid_edge_force(make_napari_viewer, graph_3d, segmentation_3d, monkeypatch, confirm_response, expect_force_retry) Test paint event processing 1) Add a new, disconnected node (5) 2) Create an edge between node 5 and 4. This is invalid, because 4 already has an incoming edge. Therefore, the force dialog should be triggered. TP 0 1 1 1 | | | 1 2 -1-> 2 5 -2-> 2 5 / \ / \ (force) | | 2 3 4 3 4 3 4