Module Gnumed.wxpython.gmGuiTest
GNUmed GUI widget testing framework.
Functions
def get_patient()-
Expand source code
def get_patient(): return gmPerson.gmCurrentPatient() def setup_widget_test_env(patient: int = -1)-
Expand source code
def setup_widget_test_env(patient:int=-1): """Setup widget test environment. - connect to DB - setup praxis branch - setup active patient, asking for patient if not given and not None - setup wx app - setup wx frame as topwindow Does *not* run app.MainLoop(). You will have to do that yourself like so: main_frame = setup_widget_test_env(...) my_widget = cWidgetClass(main_frame, ...) my_widget.whatever_else_is_necessary(...) wx.GetApp().MainLoop() Returns: main frame, which can be used to instantiate widgets """ gmPG2.request_login_params(setup_pool = True, force_tui = True) if not __activate_patient(patient = patient): sys.exit() gmPraxis.gmCurrentPraxisBranch.from_first_branch() gmStaff.set_current_provider_to_logged_on_user() app = inspection.InspectableApp() app.SetAssertMode(wx.APP_ASSERT_EXCEPTION | wx.APP_ASSERT_LOG) app.InitInspection() frame = wx.Frame(None, id = -1, title = _('GNUmed widget test'), size = (800, 600)) frame.CentreOnScreen(wx.BOTH) app.SetTopWindow(frame) frame.Show(True) app.ShowInspectionTool() return frameSetup widget test environment.
- connect to DB
- setup praxis branch
- setup active patient, asking for patient if not given and not None
- setup wx app
- setup wx frame as topwindow
Does not run app.MainLoop(). You will have to do that yourself like so:
main_frame = setup_widget_test_env(…) my_widget = cWidgetClass(main_frame, …) my_widget.whatever_else_is_necessary(…) wx.GetApp().MainLoop()
Returns -----= main frame, which can be used to instantiate widgets
def test_widget(widget_class,
*widget_args,
patient: int = -1,
size=None,
setup_db: bool = True,
**widget_kwargs)-
Expand source code
def test_widget(widget_class, *widget_args, patient:int=-1, size=None, setup_db:bool=True, **widget_kwargs): """Test a wxPython widget. Typical use: gmGuiTest.test_widget ( a_widget_class, # *widget_args: -1, # say, for window ID #patient = -1, # -1: ask, None: none, ID: patient #size = None, setup_db = True # use TUI for setting up DB access #, **widget_kwargs: #other kw args needed for widget ) Args: patient: None=no patient, -1=ask, else=patient PK setup_db: setup db connection using TUI """ if setup_db: gmPG2.request_login_params(setup_pool = True, force_tui = True) gmPraxis.gmCurrentPraxisBranch.from_first_branch() if not __activate_patient(patient = patient): sys.exit() app = inspection.InspectableApp() app.SetAssertMode(wx.APP_ASSERT_EXCEPTION | wx.APP_ASSERT_LOG) app.InitInspection() if size is None: size = (800, 600) frame = wx.Frame(None, id = -1, title = _('GNUmed widget test: %s') % widget_class, size = size) frame.CentreOnScreen(wx.BOTH) app.SetTopWindow(frame) widget = widget_class(frame, *widget_args, **widget_kwargs) frame.Show(True) app.ShowInspectionTool() try: app.MainLoop() except Exception: gmLog.log_stack_trace(message = 'test failure') return widgetTest a wxPython widget.
Typical use:
gmGuiTest.test_widget ( a_widget_class, # *widget_args: -1, # say, for window ID #patient = -1, # -1: ask, None: none, ID: patient #size = None, setup_db = True # use TUI for setting up DB access #, **widget_kwargs: #other kw args needed for widget )- Args
- -----=
patient- None=no patient, -1=ask, else=patient PK
setup_db- setup db connection using TUI