| Total Complexity | 2 |
| Total Lines | 38 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | from . import integ_test_base |
||
| 2 | |||
| 3 | |||
| 4 | class TestCustomEvaluateTimeout(integ_test_base.IntegTestBase): |
||
| 5 | def _get_evaluate_timeout(self) -> str: |
||
| 6 | return "3" |
||
| 7 | |||
| 8 | def test_custom_evaluate_timeout_with_script(self): |
||
| 9 | # Uncomment the following line to preserve |
||
| 10 | # test case output and other files (config, state, ect.) |
||
| 11 | # in system temp folder. |
||
| 12 | self.set_delete_temp_folder(False) |
||
| 13 | |||
| 14 | payload = """ |
||
| 15 | { |
||
| 16 | "data": { "_arg1": 1 }, |
||
| 17 | "script": |
||
| 18 | "import time\\ntime.sleep(100)\\nreturn 1" |
||
| 19 | } |
||
| 20 | """ |
||
| 21 | headers = { |
||
| 22 | "Content-Type": "application/json", |
||
| 23 | "TabPy-Client": "Integration test for testing custom evaluate timeouts " |
||
| 24 | "with scripts.", |
||
| 25 | } |
||
| 26 | |||
| 27 | conn = self._get_connection() |
||
| 28 | conn.request("POST", "/evaluate", payload, headers) |
||
| 29 | res = conn.getresponse() |
||
| 30 | actual_error_message = res.read().decode("utf-8") |
||
| 31 | |||
| 32 | self.assertEqual(408, res.status) |
||
| 33 | self.assertEqual( |
||
| 34 | '{"message": ' |
||
| 35 | '"User defined script timed out. Timeout is set to 3.0 s.", ' |
||
| 36 | '"info": {}}', |
||
| 37 | actual_error_message, |
||
| 38 | ) |
||
| 39 |