(self)
| 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') |
nothing calls this directly
no test coverage detected