55import pytest
66from bec_lib .bl_states import DeviceWithinLimitsStateConfig
77
8- from bec_widgets . widgets . services . beamline_states . beamline_state_pill import BeamlineStateManager
9-
8+ # pylint: disable=unused-argument
9+ # pylint: disable=redefined-outer-name
1010# pylint: disable=protected-access
1111
1212
@@ -16,57 +16,57 @@ def _delete_state_if_present(bec, state_name: str) -> None:
1616
1717
1818@pytest .mark .timeout (100 )
19- def test_beamline_state_manager_adds_updates_and_deletes_state_e2e (qtbot , bec_client_lib ):
19+ def test_beamline_state_manager_adds_updates_and_deletes_state_e2e (
20+ qtbot , bec_client_lib , connected_client_gui_obj
21+ ):
2022 """
21- Verify the real BEC beamline-state flow is reflected by BeamlineStateManager.
22-
23- This test requires the e2e BEC servers and is intended to be run with
24- ``--start-servers``.
23+ Verify the real BEC beamline-state flow is reflected by a BeamlineStateManager
24+ running in the GUI server, accessed through the dock area RPC interface.
2525 """
26+ gui = connected_client_gui_obj
27+ dock_area = gui .bec
2628 bec = bec_client_lib
2729 dev = bec .device_manager .devices
2830 scans = bec .scans
31+
2932 state_name = f"samx_widget_limits_{ uuid .uuid4 ().hex [:8 ]} "
3033 config = DeviceWithinLimitsStateConfig (
3134 name = state_name , device = "samx" , signal = "samx" , low_limit = 0.0 , high_limit = 10.0 , tolerance = 1.0
3235 )
33- manager = BeamlineStateManager (client = bec )
34- qtbot .addWidget (manager )
35- manager .show ()
36- qtbot .waitExposed (manager )
36+
37+ manager = dock_area .new ("BeamlineStateManager" )
38+ qtbot .waitUntil (lambda : manager ._gui_id in gui ._server_registry , timeout = 5000 )
39+
40+ def state_entry () -> dict [str , str ]:
41+ return manager .state_summary ().get (state_name , {})
3742
3843 _delete_state_if_present (bec , state_name )
3944
4045 try :
4146 bec .beamline_states .add (config )
4247
4348 qtbot .waitUntil (lambda : hasattr (bec .beamline_states , state_name ), timeout = 10000 )
44- qtbot .waitUntil (lambda : state_name in manager ._state_pills , timeout = 10000 )
45-
46- pill = manager ._state_pills [state_name ]
47- assert pill .state_name == state_name
49+ qtbot .waitUntil (lambda : state_name in manager .state_summary (), timeout = 10000 )
4850
4951 scans .umv (dev .samx , 5 , relative = False ).wait ()
5052 qtbot .waitUntil (
5153 lambda : getattr (bec .beamline_states , state_name ).get ()["status" ] == "valid" ,
5254 timeout = 10000 ,
5355 )
54- qtbot .waitUntil (lambda : pill ._status == "valid" , timeout = 10000 )
55- assert pill ._status_label .text () == "VALID"
56- assert pill ._detail_label .text () == "Device samx within limits"
56+ qtbot .waitUntil (lambda : state_entry ().get ("status" ) == "valid" , timeout = 10000 )
57+ assert state_entry ()["label" ] == "Device samx within limits"
5758
5859 scans .umv (dev .samx , 20 , relative = False ).wait ()
5960 qtbot .waitUntil (
6061 lambda : getattr (bec .beamline_states , state_name ).get ()["status" ] == "invalid" ,
6162 timeout = 10000 ,
6263 )
63- qtbot .waitUntil (lambda : pill ._status == "invalid" , timeout = 10000 )
64- assert pill ._status_label .text () == "INVALID"
65- assert pill ._detail_label .text () == "Device samx out of limits"
64+ qtbot .waitUntil (lambda : state_entry ().get ("status" ) == "invalid" , timeout = 10000 )
65+ assert state_entry ()["label" ] == "Device samx out of limits"
6666
6767 bec .beamline_states .delete (state_name )
6868 qtbot .waitUntil (lambda : not hasattr (bec .beamline_states , state_name ), timeout = 10000 )
69- qtbot .waitUntil (lambda : state_name not in manager ._state_pills , timeout = 10000 )
69+ qtbot .waitUntil (lambda : state_name not in manager .state_summary () , timeout = 10000 )
7070
7171 finally :
7272 _delete_state_if_present (bec , state_name )
0 commit comments