MCPcopy Create free account
hub / github.com/bugy/script-server / setUp

Method setUp

src/tests/web/script_config_socket_test.py:225–279  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

223 return tornado.websocket.websocket_connect(url)
224
225 def setUp(self):
226 super().setUp()
227
228 self.socket = None
229
230 application = tornado.web.Application([(r'/scripts/([^/]*)', ScriptConfigSocket)],
231 login_url='/login.html',
232 cookie_secret='12345')
233 application.auth = TornadoAuth(None)
234 application.authorizer = Authorizer(ANY_USER, [], [], [], EmptyGroupProvider())
235 application.identification = IpBasedIdentification(TrustedIpValidator(['127.0.0.1']), None)
236 application.config_service = ConfigService(
237 application.authorizer, test_utils.temp_folder, test_utils.process_invoker)
238
239 server = httpserver.HTTPServer(application)
240 socket, self.port = testing.bind_unused_port()
241 server.add_socket(socket)
242
243 test_utils.setup()
244
245 for dir in ['x', 'y', 'z']:
246 for file in range(1, 4):
247 filename = dir + str(file) + '.txt'
248 test_utils.create_file(os.path.join('test1_files', dir, filename))
249
250 test1_files_path = os.path.join(test_utils.temp_folder, 'test1_files')
251 test_utils.write_script_config(
252 {'name': 'Test script 1',
253 'script_path': 'ls',
254 'include': '${text 1}.json',
255 'preload_script': {
256 'script': 'echo 123'
257 },
258 'parameters': [
259 test_utils.create_script_param_config('text 1', required=True),
260 test_utils.create_script_param_config('list 1', type='list',
261 allowed_values=['A', 'B', 'C'],
262 values_ui_mapping={'A': 'Value a', 'C': 'Customer'},
263 default='C'),
264 test_utils.create_script_param_config('file 1', type='server_file',
265 file_dir=test1_files_path,
266 ui_separator_type='line',
267 ui_separator_title='Some title'),
268 test_utils.create_script_param_config('list 2', type='list',
269 values_script='ls ${file 1}')
270 ]},
271 'test_script_1')
272
273 test_utils.write_script_config(
274 {
275 'parameters': [
276 test_utils.create_script_param_config('included constant', constant=True, default='abc'),
277 test_utils.create_script_param_config('included text 2'),
278 ]},
279 'included')
280
281 def tearDown(self) -> None:
282 if self.socket:

Callers

nothing calls this directly

Calls 6

TornadoAuthClass · 0.90
AuthorizerClass · 0.90
EmptyGroupProviderClass · 0.90
TrustedIpValidatorClass · 0.90
ConfigServiceClass · 0.90

Tested by

no test coverage detected