wolfhece._builtin_plugins.grid_adder.tests.test_companion ========================================================= .. py:module:: wolfhece._builtin_plugins.grid_adder.tests.test_companion .. autoapi-nested-parse:: Unit tests for GridAdderCompanion. Running these tests ------------------- From the project root:: pytest wolfhece/_builtin_plugins/grid_adder/tests/ -v Mocking strategy ---------------- The companion needs a ``WolfMapViewer`` instance but tests run **headless** (no wx.App, no OpenGL context). ``viewer`` fixture A :class:`~unittest.mock.MagicMock` with ``xmin`` / ``xmax`` set. It records every call to ``add_object``, ``set_status_text``, etc. ``dialogs`` fixture A :class:`~unittest.mock.MagicMock` injected as the ``DialogProvider`` so we control what ``ask_float`` returns without any wx dialog appearing. Module Contents --------------- .. py:function:: viewer() .. py:function:: dialogs() .. py:data:: _COMPANION_FILE .. py:data:: _spec :value: None .. py:data:: _mod :value: None .. py:data:: GridAdderCompanion .. py:function:: _new_companion(viewer, dialogs) .. py:class:: TestGridAdderCompanion Behaviour tests — no wx, no OpenGL required. .. py:method:: test_construction(viewer, dialogs) .. py:method:: test_start_calls_add_object_when_confirmed(viewer, dialogs) When the user confirms the dialog, add_object must be called once. .. py:method:: test_start_does_not_call_add_object_when_cancelled(viewer, dialogs) When the user cancels the dialog, add_object must NOT be called. .. py:method:: test_default_size_passed_to_dialog(viewer, dialogs) The dialog must be opened with the default cell size of 1000. .. py:method:: test_status_set_after_add(viewer, dialogs) A status message must be emitted after successfully adding the grid. .. py:method:: test_menu_build_idempotent(viewer, dialogs) Calling menu_build twice must not raise (guards run without wx). .. py:method:: test_on_add_delegates_to_start(viewer, dialogs) The menu handler _on_add must call _do_add_grid via start().