Test Failed
Push — master ( 94b1f7...ff0954 )
by Oleksandr
12:55 queued 02:06
created

test_custom_evaluate_timeout   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 19
dl 0
loc 38
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A tests.integration.test_custom_evaluate_timeout.TestCustomEvaluateTimeout._get_evaluate_timeout() 0 2 1
A tests.integration.test_custom_evaluate_timeout.TestCustomEvaluateTimeout.test_custom_evaluate_timeout_with_script() 0 30 1
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