-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_callback_with_timeout.py
More file actions
46 lines (38 loc) · 1.52 KB
/
test_callback_with_timeout.py
File metadata and controls
46 lines (38 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""Tests for callback operation permutations."""
import pytest
from aws_durable_execution_sdk_python.execution import InvocationStatus
from src.callback import callback_with_timeout
@pytest.mark.example
@pytest.mark.durable_execution(
handler=callback_with_timeout.handler,
lambda_function_name="Callback With Heartbeat Timeout",
)
def test_callback_with_heartbeat_timeout(durable_runner):
"""Test callback with custom timeout configuration."""
test_payload = {"timeoutType": "heartbeat"}
with durable_runner:
result = durable_runner.run(input=test_payload, timeout=20)
assert result.status is InvocationStatus.FAILED
error = result.error
assert error is not None
assert error.message == "Callback timed out on heartbeat"
assert error.type == "CallbackError"
assert error.data is None
assert error.stack_trace is None
@pytest.mark.example
@pytest.mark.durable_execution(
handler=callback_with_timeout.handler,
lambda_function_name="Callback With General Timeout",
)
def test_callback_with_general_timeout(durable_runner):
"""Test callback with custom timeout configuration."""
test_payload = {"timeoutType": "general"}
with durable_runner:
result = durable_runner.run(input=test_payload, timeout=20)
assert result.status is InvocationStatus.FAILED
error = result.error
assert error is not None
assert error.message == "Callback timed out"
assert error.type == "CallbackError"
assert error.data is None
assert error.stack_trace is None