From e3d0d5566c50f6a80ba861d4e3e0789f17785a46 Mon Sep 17 00:00:00 2001 From: wakonig_k Date: Mon, 28 Apr 2025 15:38:50 +0200 Subject: [PATCH] test: add IPython client GUI object test module with tab completion --- tests/end-2-end/test_bec_gui_ipython.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/end-2-end/test_bec_gui_ipython.py diff --git a/tests/end-2-end/test_bec_gui_ipython.py b/tests/end-2-end/test_bec_gui_ipython.py new file mode 100644 index 00000000..9cd22a26 --- /dev/null +++ b/tests/end-2-end/test_bec_gui_ipython.py @@ -0,0 +1,25 @@ +""" +Test module for the gui object within the BEC IPython client. +""" + +from unittest import mock + +import IPython +import pytest + + +@pytest.fixture +def bec_ipython_shell(connected_client_gui_obj, bec_client_lib): + with mock.patch("IPython.core.history.HistoryManager.enabled", False): + shell = IPython.terminal.interactiveshell.TerminalInteractiveShell.instance() # type: ignore + shell.user_ns["dev"] = bec_client_lib.device_manager.devices + shell.user_ns["gui"] = connected_client_gui_obj + completer = IPython.get_ipython().Completer # type: ignore + yield shell, completer + + +def test_ipython_tab_completion(bec_ipython_shell): + _, completer = bec_ipython_shell + assert "gui.bec" in completer.all_completions("gui.") + assert "gui.bec.new" in completer.all_completions("gui.bec.") + assert "gui.bec.panels" in completer.all_completions("gui.bec.pan")