@@ -53,6 +53,9 @@ def test_run_input_file_not_found(
5353 entrypoint : str ,
5454 ):
5555 with runner .isolated_filesystem (temp_dir = temp_dir ):
56+ file_path = os .path .join (temp_dir , entrypoint )
57+ with open (file_path , "w" ) as f :
58+ f .write ("script content" )
5659 result = runner .invoke (run , [entrypoint , "--file" , "not-here.json" ])
5760 assert result .exit_code != 0
5861 assert "Error: Invalid value for '-f' / '--file'" in result .output
@@ -65,12 +68,15 @@ def test_run_invalid_input_file(
6568 ):
6669 file_name = "not-json.txt"
6770 with runner .isolated_filesystem (temp_dir = temp_dir ):
71+ script_file_path = os .path .join (temp_dir , entrypoint )
72+ with open (script_file_path , "w" ) as f :
73+ f .write ("script content" )
6874 file_path = os .path .join (temp_dir , file_name )
6975 with open (file_path , "w" ) as f :
7076 f .write ("file content" )
71- result = runner .invoke (run , [entrypoint , "--file" , file_path ])
77+ result = runner .invoke (run , [script_file_path , "--file" , file_path ])
7278 assert result .exit_code == 1
73- assert "Input file extension must be '.json'. " in result .output
79+ assert "Invalid Input File Extension " in result .output
7480
7581 def test_run_input_file_success (
7682 self ,
@@ -100,7 +106,14 @@ def test_run_input_file_success(
100106 assert "Successful execution." in result .output
101107 assert mock_middleware .call_count == 1
102108 assert mock_middleware .call_args == mock .call (
103- "run" , entrypoint , json_content , False
109+ "run" ,
110+ entrypoint ,
111+ "{}" ,
112+ False ,
113+ debug = False ,
114+ debug_port = 5678 ,
115+ input_file = file_path ,
116+ execution_output_file = None ,
104117 )
105118
106119 class TestMiddleware :
@@ -134,6 +147,7 @@ def test_successful_execution(
134147 simple_script : str ,
135148 ):
136149 input_file_name = "input.json"
150+ output_file_name = "output.json"
137151 input_json_content = """
138152 {
139153 "message": "Hello world",
@@ -142,6 +156,7 @@ def test_successful_execution(
142156 with runner .isolated_filesystem (temp_dir = temp_dir ):
143157 # create input file
144158 input_file_path = os .path .join (temp_dir , input_file_name )
159+ output_file_path = os .path .join (temp_dir , output_file_name )
145160 with open (input_file_path , "w" ) as f :
146161 f .write (input_json_content )
147162 # Create test script
@@ -152,11 +167,22 @@ def test_successful_execution(
152167 with open ("uipath.json" , "w" ) as f :
153168 f .write (uipath_json .to_json ())
154169 result = runner .invoke (
155- run , [script_file_path , "--file" , input_file_path ]
170+ run ,
171+ [
172+ script_file_path ,
173+ "--input-file" ,
174+ input_file_path ,
175+ "--output-file" ,
176+ output_file_path ,
177+ ],
156178 )
157179 assert result .exit_code == 0
158180 assert "Successful execution." in result .output
159181 assert result .output .count ("Hello world" ) == 2
182+ assert os .path .exists (output_file_path )
183+ with open (output_file_path , "r" ) as f :
184+ output = f .read ()
185+ assert output .count ("Hello world" ) == 2
160186
161187 def test_no_main_function_found (
162188 self ,
0 commit comments