@@ -114,39 +114,39 @@ def test_no_server(self, qtbot):
114114 """
115115 with mock .patch ("PyQt5.QtWidgets.QMessageBox.critical" ) as mock_critical :
116116 self .query_server (qtbot , f"{ self .scheme } ://{ self .host } :{ self .port - 1 } " )
117- qtbot .waitUntil ( lambda : mock_critical .call_count == 1 , timeout = 3000 )
117+ qtbot .wait_until ( mock_critical .assert_called_once )
118118
119119 def test_no_schema (self , qtbot ):
120120 """
121121 assert that a message box informs about server troubles
122122 """
123123 with mock .patch ("PyQt5.QtWidgets.QMessageBox.critical" ) as mock_critical :
124124 self .query_server (qtbot , f"{ self .host } :{ self .port } " )
125- qtbot .waitUntil ( lambda : mock_critical .call_count == 1 , timeout = 3000 )
125+ qtbot .wait_until ( mock_critical .assert_called_once )
126126
127127 def test_invalid_schema (self , qtbot ):
128128 """
129129 assert that a message box informs about server troubles
130130 """
131131 with mock .patch ("PyQt5.QtWidgets.QMessageBox.critical" ) as mock_critical :
132132 self .query_server (qtbot , f"hppd://{ self .host } :{ self .port } " )
133- qtbot .waitUntil ( lambda : mock_critical .call_count == 1 , timeout = 3000 )
133+ qtbot .wait_until ( mock_critical .assert_called_once )
134134
135135 def test_invalid_url (self , qtbot ):
136136 """
137137 assert that a message box informs about server troubles
138138 """
139139 with mock .patch ("PyQt5.QtWidgets.QMessageBox.critical" ) as mock_critical :
140140 self .query_server (qtbot , f"{ self .scheme } ://???{ self .host } :{ self .port } " )
141- qtbot .waitUntil ( lambda : mock_critical .call_count == 1 , timeout = 3000 )
141+ qtbot .wait_until ( mock_critical .assert_called_once )
142142
143143 def test_connection_error (self , qtbot ):
144144 """
145145 assert that a message box informs about server troubles
146146 """
147147 with mock .patch ("PyQt5.QtWidgets.QMessageBox.critical" ) as mock_critical :
148148 self .query_server (qtbot , f"{ self .scheme } ://.....{ self .host } :{ self .port } " )
149- qtbot .waitUntil ( lambda : mock_critical .call_count == 1 , timeout = 3000 )
149+ qtbot .wait_until ( mock_critical .assert_called_once )
150150
151151 @pytest .mark .skip ("Breaks other tests in this class because of a lingering message box, for some reason" )
152152 def test_forward_backward_clicks (self , qtbot ):
@@ -186,11 +186,8 @@ def test_server_getmap(self, qtbot):
186186 """
187187 self .query_server (qtbot , self .url )
188188
189- try :
190- with qtbot .wait_signal (self .window .image_displayed , timeout = 5000 ):
191- QtTest .QTest .mouseClick (self .window .btGetMap , QtCore .Qt .LeftButton )
192- except TimeoutError :
193- pytest .fail ("Timeout: image_displayed was not emitted." )
189+ with qtbot .wait_signal (self .window .image_displayed ):
190+ QtTest .QTest .mouseClick (self .window .btGetMap , QtCore .Qt .LeftButton )
194191
195192 assert self .view .draw_image .call_count == 1
196193 assert self .view .draw_legend .call_count == 1
@@ -393,8 +390,7 @@ def test_multilayer_syncing(self, qtbot):
393390 assert layer_a .get_itime () == layer_a .get_itimes ()[- 1 ]
394391
395392 @mock .patch ("mslib.msui.wms_control.WMSMapFetcher.moveToThread" )
396- def test_server_no_thread (self , mockthread , qtbot , mswms_server ):
397- assert self .url == mswms_server .rstrip ("/" )
393+ def test_server_no_thread (self , mockthread , qtbot ):
398394 self .query_server (qtbot , self .url )
399395 server = self .window .multilayers .listLayers .findItems (f"{ self .url } /" ,
400396 QtCore .Qt .MatchFixedString )[0 ]
@@ -404,42 +400,12 @@ def test_server_no_thread(self, mockthread, qtbot, mswms_server):
404400 server .child (0 ).setCheckState (0 , 2 )
405401 server .child (1 ).setCheckState (0 , 2 )
406402
407- # Mock the actual fetching so that no real HTTP call happens.
408- self .window .fetcher .fetch_map = mock .MagicMock ()
409- self .window .fetcher .fetch_legend = mock .MagicMock ()
410-
411- # Make sure that the signal is emitted on click
412- def _emit_image_displayed (* args , ** kwargs ):
413- self .window .image_displayed .emit ()
414-
415- self .window .btGetMap .clicked .connect (_emit_image_displayed )
416-
417- # Ensure the signal actually triggers the view update
418- self .window .image_displayed .connect (self .view .draw_image )
419-
420- # NEW: Ensure metadata drawing is triggered when image is displayed
421- def _emit_metadata_displayed (* args , ** kwargs ):
422- self .window .metadata_displayed .emit ()
423-
424- self .window .btGetMap .clicked .connect (_emit_metadata_displayed )
425- self .window .metadata_displayed .connect (self .view .draw_metadata )
426-
427- # Ensure legend drawing is triggered when fetch_legend is called
428- def _emit_legend_displayed (* args , ** kwargs ):
429- # only emit when we simulate a non-cached fetch
430- if kwargs .get ("use_cache" ) is False :
431- self .window .legend_displayed .emit ()
432-
433- self .window .legend_displayed .connect (self .view .draw_legend )
434- self .window .fetcher .fetch_legend .side_effect = _emit_legend_displayed
435-
436- with qtbot .wait_signal (self .window .image_displayed , timeout = 5000 ):
403+ with qtbot .wait_signal (self .window .image_displayed ):
437404 QtTest .QTest .mouseClick (self .window .btGetMap , QtCore .Qt .LeftButton )
438405
439406 urlstr = f"{ self .url } /mss/logo.png"
440407 md5_filname = os .path .join (self .window .wms_cache , hashlib .md5 (urlstr .encode ('utf-8' )).hexdigest () + ".png" )
441- with qtbot .wait_signal (self .window .legend_displayed , timeout = 2000 ):
442- self .window .fetcher .fetch_legend (urlstr , use_cache = False , md5_filename = md5_filname )
408+ self .window .fetcher .fetch_legend (urlstr , use_cache = False , md5_filename = md5_filname )
443409 self .window .fetcher .fetch_legend (urlstr , use_cache = True , md5_filename = md5_filname )
444410
445411 assert self .view .draw_image .call_count == 1
0 commit comments