@@ -89,7 +89,7 @@ def test_get_alerts(
89
89
else :
90
90
assert len (_alerts ) == 2
91
91
assert f"user_alert_2_{ unique_id } " in _alerts
92
-
92
+
93
93
@pytest .mark .dependency
94
94
@pytest .mark .client
95
95
def test_get_run_id_from_name (create_test_run : tuple [sv_run .Run , dict ]) -> None :
@@ -273,46 +273,35 @@ def test_get_tag(create_plain_run: tuple[sv_run.Run, dict]) -> None:
273
273
assert any (tag .name == run_data ["tags" ][- 1 ] for _ , tag in client .get_tags ())
274
274
275
275
276
- PRE_DELETION_TESTS : list [str ] = [
277
- "test_get_metrics" ,
278
- "test_get_runs" ,
279
- "test_get_run" ,
280
- "test_get_artifact_as_file" ,
281
- "test_get_artifacts_as_files" ,
282
- "test_get_folders" ,
283
- "test_get_metrics_names" ,
284
- "test_get_metrics_multiple" ,
285
- "test_plot_metrics" ,
286
- "test_get_run_id_from_name" ,
287
- "test_get_folder" ,
288
- "test_get_tags"
289
- ]
290
-
291
-
292
276
@pytest .mark .dependency
293
- @pytest .mark .client ( depends = PRE_DELETION_TESTS )
277
+ @pytest .mark .client
294
278
def test_run_deletion () -> None :
295
279
run = sv_run .Run ()
296
280
run .init (name = "test_run_deletion" , folder = "/simvue_unit_testing" , tags = ["test_run_deletion" ], retention_period = "1 min" )
297
281
run .log_metrics ({"x" : 2 })
298
282
run .close ()
299
283
client = svc .Client ()
300
284
assert not client .delete_run (run .id )
285
+ with pytest .raises (ObjectNotFoundError ):
286
+ client .get_run (run .id )
301
287
302
288
303
289
@pytest .mark .dependency
304
- @pytest .mark .client ( depends = PRE_DELETION_TESTS )
290
+ @pytest .mark .client
305
291
def test_runs_deletion () -> None :
306
292
_runs = [sv_run .Run () for _ in range (5 )]
307
293
for i , run in enumerate (_runs ):
308
294
run .init (name = "test_runs_deletion" , folder = "/simvue_unit_testing/runs_batch" , tags = ["test_runs_deletion" ], retention_period = "1 min" )
309
295
run .log_metrics ({"x" : i })
310
296
client = svc .Client ()
311
297
assert len (client .delete_runs ("/simvue_unit_testing/runs_batch" )) > 0
298
+ for run in _runs :
299
+ with pytest .raises (ObjectNotFoundError ):
300
+ client .get_run (run .id )
312
301
313
302
314
303
@pytest .mark .dependency
315
- @pytest .mark .client ( depends = PRE_DELETION_TESTS )
304
+ @pytest .mark .client
316
305
def test_get_tags (create_plain_run : tuple [sv_run .Run , dict ]) -> None :
317
306
run , run_data = create_plain_run
318
307
tags = run_data ["tags" ]
@@ -324,14 +313,18 @@ def test_get_tags(create_plain_run: tuple[sv_run.Run, dict]) -> None:
324
313
325
314
326
315
@pytest .mark .dependency
327
- @pytest .mark .client (depends = PRE_DELETION_TESTS + ["test_runs_deletion" ])
328
- def test_folder_deletion (create_test_run : tuple [sv_run .Run , dict ]) -> None :
329
- run , run_data = create_test_run
316
+ @pytest .mark .client
317
+ def test_folder_deletion () -> None :
318
+ run = sv_run .Run ()
319
+ run .init (name = "test_folder_deletion" , folder = "/simvue_unit_testing/delete_me" , tags = ["test_folder_deletion" ], retention_period = "1 min" )
330
320
run .close ()
331
321
client = svc .Client ()
332
322
# This test is called last, one run created so expect length 1
333
- assert len (client .delete_folder (run_data ["folder" ], remove_runs = True )) == 1
334
- assert not client .get_folder (run_data ["folder" ])
323
+ assert len (client .delete_folder ("/simvue_unit_testing/delete_me" , remove_runs = True )) == 1
324
+ time .sleep (10 )
325
+ assert not client .get_folder ("/simvue_unit_testing/delete_me" )
326
+ with pytest .raises (ObjectNotFoundError ):
327
+ client .get_run (run_id = run .id )
335
328
336
329
337
330
@pytest .mark .client
@@ -348,20 +341,20 @@ def test_run_folder_metadata_find(create_plain_run: tuple[sv_run.Run, dict]) ->
348
341
349
342
350
343
@pytest .mark .client
351
- def test_tag_deletion (create_plain_run : tuple [sv_run .Run , dict ]) -> None :
352
- run , run_data = create_plain_run
344
+ def test_tag_deletion () -> None :
345
+ run = sv_run .Run ()
346
+ run .init (name = "test_folder_deletion" , folder = "/simvue_unit_testing/delete_me" , tags = ["test_tag_deletion" ], retention_period = "1 min" )
347
+ run .close ()
353
348
unique_id = f"{ uuid .uuid4 ()} " .split ("-" )[0 ]
354
- run .update_tags ([f"delete_me_{ unique_id } " ])
349
+ run .update_tags ([( tag_str := f"delete_me_{ unique_id } " ) ])
355
350
run .close ()
356
- time .sleep (1.0 )
357
351
client = svc .Client ()
358
352
tags = client .get_tags ()
359
353
client .delete_run (run .id )
360
- time .sleep (1.0 )
361
- tag_identifier = [identifier for identifier , tag in tags if tag .name == f"delete_me_{ unique_id } " ][0 ]
354
+ tag_identifier = [identifier for identifier , tag in tags if tag .name == tag_str ][0 ]
362
355
client .delete_tag (tag_identifier )
363
- time . sleep ( 1.0 )
364
- assert not client .get_tag (tag_identifier )
356
+ with pytest . raises ( ObjectNotFoundError ):
357
+ client .get_tag (tag_identifier )
365
358
366
359
367
360
@pytest .mark .dependency
@@ -407,9 +400,7 @@ def test_alert_deletion() -> None:
407
400
_alert = sv_api_obj .UserAlert .new (name = "test_alert" , notification = "none" , description = None )
408
401
_alert .commit ()
409
402
_client = svc .Client ()
410
- time .sleep (1 )
411
403
_client .delete_alert (alert_id = _alert .id )
412
-
413
404
with pytest .raises (ObjectNotFoundError ) as e :
414
405
sv_api_obj .Alert (identifier = _alert .id )
415
406
0 commit comments