3030
3131from lsst .ts .idl .enums .Script import ScriptState
3232from lsst .ts import salobj
33- from lsst .ts . scriptqueue import ui
33+ from lsst .ts import scriptqueue
3434
3535# Long enough to perform any reasonable operation
3636# including starting a CSC or loading a script (seconds)
4242class ParseRunOneScriptTestCase (unittest .IsolatedAsyncioTestCase ):
4343 def test_basics (self ):
4444 script = DATA_DIR / "standard" / "subdir" / "script3"
45- cmd = ui .parse_run_one_script_cmd (args = [str (script )])
45+ cmd = scriptqueue .parse_run_one_script_cmd (args = [str (script )])
4646 assert script .samefile (cmd .script )
4747 assert cmd .config == ""
4848
@@ -51,7 +51,7 @@ def test_config_arg(self):
5151 config_path = DATA_DIR / "config1.yaml"
5252 with open (config_path , "r" ) as f :
5353 expected_config = f .read ()
54- cmd = ui .parse_run_one_script_cmd (
54+ cmd = scriptqueue .parse_run_one_script_cmd (
5555 args = [str (script ), "--config" , config_path .as_posix ()]
5656 )
5757 assert script .samefile (cmd .script )
@@ -61,7 +61,7 @@ def test_parameters_arg(self):
6161 script = DATA_DIR / "external" / "script1"
6262 config_dict = dict (abool = True , anint = 47 , afloat = 0.2 , astr = "string_value" )
6363 config_arg_list = [f"{ key } ={ value } " for key , value in config_dict .items ()]
64- cmd = ui .parse_run_one_script_cmd (
64+ cmd = scriptqueue .parse_run_one_script_cmd (
6565 args = [str (script ), "--parameters" ] + config_arg_list
6666 )
6767 assert script .samefile (cmd .script )
@@ -70,17 +70,19 @@ def test_parameters_arg(self):
7070
7171 def test_loglevel (self ):
7272 script = DATA_DIR / "external" / "script1"
73- cmd = ui .parse_run_one_script_cmd (args = [str (script )])
73+ cmd = scriptqueue .parse_run_one_script_cmd (args = [str (script )])
7474 assert cmd .loglevel is None
7575
7676 loglevel = 15
77- cmd = ui .parse_run_one_script_cmd (
77+ cmd = scriptqueue .parse_run_one_script_cmd (
7878 args = [str (script ), "--loglevel" , str (loglevel )]
7979 )
8080 assert cmd .loglevel == loglevel
8181
8282 loglevel = 21
83- cmd = ui .parse_run_one_script_cmd (args = [str (script ), "-l" , str (loglevel )])
83+ cmd = scriptqueue .parse_run_one_script_cmd (
84+ args = [str (script ), "-l" , str (loglevel )]
85+ )
8486 assert cmd .loglevel == loglevel
8587
8688 def test_invalid_arguments (self ):
@@ -89,49 +91,51 @@ def test_invalid_arguments(self):
8991
9092 with pytest .raises (SystemExit ):
9193 # need type and path
92- ui .parse_run_one_script_cmd (args = [])
94+ scriptqueue .parse_run_one_script_cmd (args = [])
9395 with pytest .raises (SystemExit ):
9496 # there is only one allowed positional arguments
95- ui .parse_run_one_script_cmd (args = [str (script ), "extra_argument" ])
97+ scriptqueue .parse_run_one_script_cmd (args = [str (script ), "extra_argument" ])
9698 with pytest .raises (SystemExit ):
9799 # invalid option
98- ui .parse_run_one_script_cmd (args = [str (script ), "--invalid" ])
100+ scriptqueue .parse_run_one_script_cmd (args = [str (script ), "--invalid" ])
99101 with pytest .raises (SystemExit ):
100102 # nonexistent config file
101- ui .parse_run_one_script_cmd (
103+ scriptqueue .parse_run_one_script_cmd (
102104 args = [str (script ), "--config" , "nonexistent_config_file.yaml" ]
103105 )
104106 with pytest .raises (SystemExit ):
105107 # --index must have a value if specified
106- ui .parse_run_one_script_cmd (args = [str (script ), "--index" ])
108+ scriptqueue .parse_run_one_script_cmd (args = [str (script ), "--index" ])
107109 with pytest .raises (SystemExit ):
108110 # --index must be > 0
109- ui .parse_run_one_script_cmd (args = [str (script ), "--index" , "0" ])
111+ scriptqueue .parse_run_one_script_cmd (args = [str (script ), "--index" , "0" ])
110112 with pytest .raises (SystemExit ):
111113 # --index must be <= salobj.MAX_SAL_INDEX
112114 too_large_index = salobj .MAX_SAL_INDEX + 1
113- ui .parse_run_one_script_cmd (
115+ scriptqueue .parse_run_one_script_cmd (
114116 args = [str (script ), "--index" , str (too_large_index )]
115117 )
116118 with pytest .raises (SystemExit ):
117119 # --index must be an integer
118- ui .parse_run_one_script_cmd (args = [str (script ), "--index" , "not_an_integer" ])
120+ scriptqueue .parse_run_one_script_cmd (
121+ args = [str (script ), "--index" , "not_an_integer" ]
122+ )
119123 with pytest .raises (SystemExit ):
120124 # --parameters requires data
121- ui .parse_run_one_script_cmd (args = [str (script ), "--parameters" ])
125+ scriptqueue .parse_run_one_script_cmd (args = [str (script ), "--parameters" ])
122126 with pytest .raises (SystemExit ):
123127 # invalid data for --parameters; no =
124- ui .parse_run_one_script_cmd (
128+ scriptqueue .parse_run_one_script_cmd (
125129 args = [str (script ), "--parameters" , "invalid_parameter" ]
126130 )
127131 with pytest .raises (SystemExit ):
128132 # invalid data for --parameters; space
129- ui .parse_run_one_script_cmd (
133+ scriptqueue .parse_run_one_script_cmd (
130134 args = [str (script ), "--parameters" , "wait_time" , "=" , "0.1" ]
131135 )
132136 with pytest .raises (SystemExit ):
133137 # cannot specify both --config and --parameters
134- ui .parse_run_one_script_cmd (
138+ scriptqueue .parse_run_one_script_cmd (
135139 args = [
136140 str (script ),
137141 "--config" ,
@@ -151,7 +155,9 @@ async def test_run_one_script(self):
151155 config_path = DATA_DIR / "config1.yaml"
152156 with open (config_path , "r" ) as f :
153157 config = f .read ()
154- await ui .run_one_script (index = 1 , script = script , config = config , loglevel = 10 )
158+ await scriptqueue .run_one_script (
159+ index = 1 , script = script , config = config , loglevel = 10
160+ )
155161
156162 async def test_run_command_line (self ):
157163 exe_name = "run_one_script"
0 commit comments