MCPcopy Index your code
hub / github.com/bugy/script-server / test_create_script_config

Method test_create_script_config

src/tests/web/server_test.py:169–199  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

167 response)
168
169 def test_create_script_config(self):
170 self.start_server(12345, '127.0.0.1')
171
172 xsrf_token = self.get_xsrf_token(self._admin_session)
173
174 response = self._admin_session.post(
175 'http://127.0.0.1:12345/admin/scripts',
176 data={'filename': 'whatever', 'config': json.dumps({
177 'name': 'test conf',
178 'script': {
179 'mode': 'upload_script',
180 'path': 'whatever'
181 }
182 })},
183 files={'uploadedScript': ('my.py', b'script content')},
184 headers={'X-XSRFToken': xsrf_token},
185 )
186
187 self.assertEqual(200, response.status_code)
188
189 expected_script_path = os.path.join(test_utils.temp_folder, 'conf', 'scripts', 'my.py')
190
191 conf_response = self.request('get', 'http://127.0.0.1:12345/admin/scripts/test%20conf',
192 self._admin_session)
193 self.assertEqual({'config': {'name': 'test conf',
194 'script_path': expected_script_path},
195 'filename': 'test_conf.json'},
196 conf_response)
197
198 script_content = file_utils.read_file(expected_script_path)
199 self.assertEqual('script content', script_content)
200
201 def test_update_script_config(self):
202 self.start_server(12345, '127.0.0.1')

Callers

nothing calls this directly

Calls 4

start_serverMethod · 0.95
get_xsrf_tokenMethod · 0.95
requestMethod · 0.95
postMethod · 0.45

Tested by

no test coverage detected