@@ -747,44 +747,57 @@ def test_set_folder_details(request: pytest.FixtureRequest) -> None:
747747 ids = [f"scenario_{ i } " for i in range (1 , 6 )],
748748)
749749def test_save_file_online (
750- create_plain_run : tuple [sv_run .Run , dict ],
751750 valid_mimetype : bool ,
752751 preserve_path : bool ,
753752 name : str | None ,
754753 allow_pickle : bool ,
755754 empty_file : bool ,
756755 category : typing .Literal ["input" , "output" , "code" ],
757756 capfd ,
757+ request ,
758758) -> None :
759- simvue_run , _ = create_plain_run
759+ _uuid = f" { uuid . uuid4 () } " . split ( "-" )[ 0 ]
760760 file_type : str = "text/plain" if valid_mimetype else "text/text"
761761 with tempfile .TemporaryDirectory () as tempd :
762762 with open (
763763 (out_name := pathlib .Path (tempd ).joinpath ("test_file.txt" )),
764764 "w" ,
765765 ) as out_f :
766766 out_f .write ("" if empty_file else "test data entry" )
767-
768- if valid_mimetype :
769- simvue_run .save_file (
770- out_name ,
771- category = category ,
772- file_type = file_type ,
773- preserve_path = preserve_path ,
774- name = name ,
767+ with sv_run .Run () as simvue_run :
768+ folder_name : str = f"/simvue_unit_testing/{ _uuid } "
769+ tags : list [str ] = [
770+ "simvue_client_unit_tests" ,
771+ "test_save_file_online"
772+ ]
773+ simvue_run .init (
774+ request .node .name .replace ("[" , "_" ).replace ("]" , "_" ),
775+ folder = folder_name ,
776+ tags = tags ,
777+ visibility = "tenant" if os .environ .get ("CI" ) else None ,
778+ retention_period = os .environ .get ("SIMVUE_TESTING_RETENTION_PERIOD" , "2 mins" ),
775779 )
776- else :
777- with pytest .raises (RuntimeError ):
780+
781+
782+ if valid_mimetype :
778783 simvue_run .save_file (
779784 out_name ,
780785 category = category ,
781786 file_type = file_type ,
782787 preserve_path = preserve_path ,
788+ name = name ,
783789 )
784- return
790+ else :
791+ with pytest .raises (RuntimeError ):
792+ simvue_run .save_file (
793+ out_name ,
794+ category = category ,
795+ file_type = file_type ,
796+ preserve_path = preserve_path ,
797+ )
798+ return
785799
786- variable = capfd .readouterr ()
787- simvue_run .close ()
800+ variable = capfd .readouterr ()
788801 time .sleep (1.0 )
789802 os .remove (out_name )
790803 client = sv_cl .Client ()
0 commit comments