@@ -194,7 +194,7 @@ def test_integration_create_get_update_delete_alert_definition(
194194 try :
195195 created = client .load (AlertDefinition , created .id , service_type )
196196 except Exception :
197-
197+ # transient errors while polling; continue until timeout
198198 pass
199199
200200 if created :
@@ -206,17 +206,24 @@ def test_integration_create_get_update_delete_alert_definition(
206206 else :
207207 pytest .fail ("Alert definition was not created successfully" )
208208
209- updated = client .load (AlertDefinition , update_alert .id , service_type )
210- while (
211- getattr (updated , "status" , None ) == "in progress"
212- and (time .time () - start ) < timeout
213- ):
214- time .sleep (interval )
215- try :
216- updated = client .load (AlertDefinition , updated .id , service_type )
217- except Exception :
218- # transient errors while polling; continue until timeout
219- pass
209+ if update_alert :
210+ updated = client .load (
211+ AlertDefinition , update_alert .id , service_type
212+ )
213+ while (
214+ getattr (updated , "status" , None ) == "in progress"
215+ and (time .time () - start ) < timeout
216+ ):
217+ time .sleep (interval )
218+ try :
219+ updated = client .load (
220+ AlertDefinition , updated .id , service_type
221+ )
222+ except Exception :
223+ # transient errors while polling; continue until timeout
224+ pass
225+ else :
226+ pytest .fail ("Alert definition was not updated successfully" )
220227
221228 assert created .id == updated .id
222229 assert updated .label == f"{ label } -updated"
@@ -231,17 +238,12 @@ def test_integration_create_get_update_delete_alert_definition(
231238 )
232239 delete_alert .delete ()
233240 except Exception :
234- pytest . fail ( "Could not delete alert definition during cleanup" )
241+ assert False , "Could not delete alert definition during cleanup"
235242 pass
236243
237244 # confirm it's gone (if API returns 404 or raises)
238245 try :
239246 client .load (AlertDefinition , created .id , service_type )
240- # If no exception, fail explicitly
241- pytest .fail ("Alert definition still retrievable after delete" )
242- except ApiError :
243- pytest .skip ("Alert definition successfully deleted" )
244- pass
247+ assert False , "Alert definition still retrievable after delete"
245248 except Exception :
246- pytest .skip ("Alert definition successfully deleted" )
247249 pass
0 commit comments