-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathinvoke_test.py
More file actions
668 lines (536 loc) · 24.1 KB
/
invoke_test.py
File metadata and controls
668 lines (536 loc) · 24.1 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
"""Unit tests for invoke handler."""
from __future__ import annotations
import json
from unittest.mock import Mock, patch
import pytest
from aws_durable_execution_sdk_python.config import Duration, InvokeConfig
from aws_durable_execution_sdk_python.exceptions import (
CallableRuntimeError,
ExecutionError,
SuspendExecution,
TimedSuspendExecution,
)
from aws_durable_execution_sdk_python.identifier import OperationIdentifier
from aws_durable_execution_sdk_python.lambda_service import (
ChainedInvokeDetails,
ErrorObject,
Operation,
OperationAction,
OperationStatus,
OperationType,
)
from aws_durable_execution_sdk_python.operation.invoke import (
invoke_handler,
suspend_with_optional_resume_delay,
)
from aws_durable_execution_sdk_python.state import CheckpointedResult, ExecutionState
from tests.serdes_test import CustomDictSerDes
def test_invoke_handler_already_succeeded():
"""Test invoke_handler when operation already succeeded."""
mock_state = Mock(spec=ExecutionState)
mock_state.durable_execution_arn = "test_arn"
operation = Operation(
operation_id="invoke1",
operation_type=OperationType.CHAINED_INVOKE,
status=OperationStatus.SUCCEEDED,
chained_invoke_details=ChainedInvokeDetails(result=json.dumps("test_result")),
)
mock_result = CheckpointedResult.create_from_operation(operation)
mock_state.get_checkpoint_result.return_value = mock_result
result = invoke_handler(
function_name="test_function",
payload="test_input",
state=mock_state,
operation_identifier=OperationIdentifier("invoke1", None, "test_invoke"),
config=None,
)
assert result == "test_result"
mock_state.create_checkpoint.assert_not_called()
def test_invoke_handler_already_succeeded_none_result():
"""Test invoke_handler when operation succeeded with None result."""
mock_state = Mock(spec=ExecutionState)
mock_state.durable_execution_arn = "test_arn"
operation = Operation(
operation_id="invoke2",
operation_type=OperationType.CHAINED_INVOKE,
status=OperationStatus.SUCCEEDED,
chained_invoke_details=ChainedInvokeDetails(result=None),
)
mock_result = CheckpointedResult.create_from_operation(operation)
mock_state.get_checkpoint_result.return_value = mock_result
result = invoke_handler(
function_name="test_function",
payload="test_input",
state=mock_state,
operation_identifier=OperationIdentifier("invoke2", None, "test_invoke"),
config=None,
)
assert result is None
def test_invoke_handler_already_succeeded_no_chained_invoke_details():
"""Test invoke_handler when operation succeeded but has no chained_invoke_details."""
mock_state = Mock(spec=ExecutionState)
mock_state.durable_execution_arn = "test_arn"
operation = Operation(
operation_id="invoke3",
operation_type=OperationType.CHAINED_INVOKE,
status=OperationStatus.SUCCEEDED,
chained_invoke_details=None,
)
mock_result = CheckpointedResult.create_from_operation(operation)
mock_state.get_checkpoint_result.return_value = mock_result
result = invoke_handler(
function_name="test_function",
payload="test_input",
state=mock_state,
operation_identifier=OperationIdentifier("invoke3", None, "test_invoke"),
config=None,
)
assert result is None
@pytest.mark.parametrize(
"kind", [OperationStatus.FAILED, OperationStatus.STOPPED, OperationStatus.TIMED_OUT]
)
def test_invoke_handler_already_terminated(kind: OperationStatus):
"""Test invoke_handler when operation already failed."""
mock_state = Mock(spec=ExecutionState)
mock_state.durable_execution_arn = "test_arn"
error = ErrorObject(
message="Test error", type="TestError", data=None, stack_trace=None
)
operation = Operation(
operation_id="invoke4",
operation_type=OperationType.CHAINED_INVOKE,
status=kind,
chained_invoke_details=ChainedInvokeDetails(error=error),
)
mock_result = CheckpointedResult.create_from_operation(operation)
mock_state.get_checkpoint_result.return_value = mock_result
with pytest.raises(CallableRuntimeError):
invoke_handler(
function_name="test_function",
payload="test_input",
state=mock_state,
operation_identifier=OperationIdentifier("invoke4", None, "test_invoke"),
config=None,
)
def test_invoke_handler_already_timed_out():
"""Test invoke_handler when operation already timed out."""
mock_state = Mock(spec=ExecutionState)
mock_state.durable_execution_arn = "test_arn"
error = ErrorObject(
message="Operation timed out", type="TimeoutError", data=None, stack_trace=None
)
operation = Operation(
operation_id="invoke5",
operation_type=OperationType.CHAINED_INVOKE,
status=OperationStatus.TIMED_OUT,
chained_invoke_details=ChainedInvokeDetails(error=error),
)
mock_result = CheckpointedResult.create_from_operation(operation)
mock_state.get_checkpoint_result.return_value = mock_result
with pytest.raises(CallableRuntimeError):
invoke_handler(
function_name="test_function",
payload="test_input",
state=mock_state,
operation_identifier=OperationIdentifier("invoke5", None, "test_invoke"),
config=None,
)
@pytest.mark.parametrize("status", [OperationStatus.STARTED])
def test_invoke_handler_already_started(status):
"""Test invoke_handler when operation is already started."""
mock_state = Mock(spec=ExecutionState)
mock_state.durable_execution_arn = "test_arn"
operation = Operation(
operation_id="invoke6",
operation_type=OperationType.CHAINED_INVOKE,
status=status,
chained_invoke_details=ChainedInvokeDetails(),
)
mock_result = CheckpointedResult.create_from_operation(operation)
mock_state.get_checkpoint_result.return_value = mock_result
with pytest.raises(SuspendExecution, match="Invoke invoke6 still in progress"):
invoke_handler(
function_name="test_function",
payload="test_input",
state=mock_state,
operation_identifier=OperationIdentifier("invoke6", None, "test_invoke"),
config=None,
)
@pytest.mark.parametrize("status", [OperationStatus.STARTED, OperationStatus.PENDING])
def test_invoke_handler_already_started_with_timeout(status):
"""Test invoke_handler when operation is already started with timeout config."""
mock_state = Mock(spec=ExecutionState)
mock_state.durable_execution_arn = "test_arn"
operation = Operation(
operation_id="invoke7",
operation_type=OperationType.CHAINED_INVOKE,
status=status,
chained_invoke_details=ChainedInvokeDetails(),
)
mock_result = CheckpointedResult.create_from_operation(operation)
mock_state.get_checkpoint_result.return_value = mock_result
config = InvokeConfig[str, str](timeout=Duration.from_seconds(30))
with pytest.raises(TimedSuspendExecution):
invoke_handler(
function_name="test_function",
payload="test_input",
state=mock_state,
operation_identifier=OperationIdentifier("invoke7", None, "test_invoke"),
config=config,
)
def test_invoke_handler_new_operation():
"""Test invoke_handler when starting a new operation."""
mock_state = Mock(spec=ExecutionState)
mock_state.durable_execution_arn = "test_arn"
mock_result = CheckpointedResult.create_not_found()
mock_state.get_checkpoint_result.return_value = mock_result
config = InvokeConfig[str, str](timeout=Duration.from_minutes(1))
with pytest.raises(
SuspendExecution, match="Invoke invoke8 started, suspending for completion"
):
invoke_handler(
function_name="test_function",
payload="test_input",
state=mock_state,
operation_identifier=OperationIdentifier("invoke8", None, "test_invoke"),
config=config,
)
# Verify checkpoint was created
mock_state.create_checkpoint.assert_called_once()
operation_update = mock_state.create_checkpoint.call_args[1]["operation_update"]
assert operation_update.operation_id == "invoke8"
assert operation_update.operation_type == OperationType.CHAINED_INVOKE
assert operation_update.action == OperationAction.START
assert operation_update.name == "test_invoke"
assert operation_update.payload == json.dumps("test_input")
assert operation_update.chained_invoke_options.function_name == "test_function"
def test_invoke_handler_new_operation_with_timeout():
"""Test invoke_handler when starting a new operation with timeout."""
mock_state = Mock(spec=ExecutionState)
mock_state.durable_execution_arn = "test_arn"
mock_result = CheckpointedResult.create_not_found()
mock_state.get_checkpoint_result.return_value = mock_result
config = InvokeConfig[str, str](timeout=Duration.from_seconds(30))
with pytest.raises(TimedSuspendExecution):
invoke_handler(
function_name="test_function",
payload="test_input",
state=mock_state,
operation_identifier=OperationIdentifier("invoke9", None, "test_invoke"),
config=config,
)
def test_invoke_handler_new_operation_no_timeout():
"""Test invoke_handler when starting a new operation without timeout."""
mock_state = Mock(spec=ExecutionState)
mock_state.durable_execution_arn = "test_arn"
mock_result = CheckpointedResult.create_not_found()
mock_state.get_checkpoint_result.return_value = mock_result
config = InvokeConfig[str, str](timeout=Duration.from_seconds(0))
with pytest.raises(SuspendExecution):
invoke_handler(
function_name="test_function",
payload="test_input",
state=mock_state,
operation_identifier=OperationIdentifier("invoke10", None, "test_invoke"),
config=config,
)
def test_invoke_handler_no_config():
"""Test invoke_handler when no config is provided."""
mock_state = Mock(spec=ExecutionState)
mock_state.durable_execution_arn = "test_arn"
mock_result = CheckpointedResult.create_not_found()
mock_state.get_checkpoint_result.return_value = mock_result
with pytest.raises(SuspendExecution):
invoke_handler(
function_name="test_function",
payload="test_input",
state=mock_state,
operation_identifier=OperationIdentifier("invoke11", None, "test_invoke"),
config=None,
)
# Verify default config was used
operation_update = mock_state.create_checkpoint.call_args[1]["operation_update"]
chained_invoke_options = operation_update.to_dict()["ChainedInvokeOptions"]
assert chained_invoke_options["FunctionName"] == "test_function"
# tenant_id should be None when not specified
assert "TenantId" not in chained_invoke_options
def test_invoke_handler_custom_serdes():
"""Test invoke_handler with custom serialization."""
mock_state = Mock(spec=ExecutionState)
mock_state.durable_execution_arn = "test_arn"
operation = Operation(
operation_id="invoke12",
operation_type=OperationType.CHAINED_INVOKE,
status=OperationStatus.SUCCEEDED,
chained_invoke_details=ChainedInvokeDetails(
result='{"key": "VALUE", "number": "84", "list": [1, 2, 3]}',
),
)
mock_result = CheckpointedResult.create_from_operation(operation)
mock_state.get_checkpoint_result.return_value = mock_result
config = InvokeConfig[dict, dict](
serdes_payload=CustomDictSerDes(), serdes_result=CustomDictSerDes()
)
result = invoke_handler(
function_name="test_function",
payload={"key": "value", "number": 42, "list": [1, 2, 3]},
state=mock_state,
operation_identifier=OperationIdentifier("invoke12", None, "test_invoke"),
config=config,
)
# CustomDictSerDes transforms the result back
assert result == {"key": "value", "number": 42, "list": [1, 2, 3]}
def test_invoke_handler_custom_serdes_new_operation():
"""Test invoke_handler with custom serialization for new operation."""
mock_state = Mock(spec=ExecutionState)
mock_state.durable_execution_arn = "test_arn"
mock_result = CheckpointedResult.create_not_found()
mock_state.get_checkpoint_result.return_value = mock_result
config = InvokeConfig[dict, dict](
serdes_payload=CustomDictSerDes(), serdes_result=CustomDictSerDes()
)
complex_payload = {"key": "value", "number": 42, "list": [1, 2, 3]}
with pytest.raises(SuspendExecution):
invoke_handler(
function_name="test_function",
payload=complex_payload,
state=mock_state,
operation_identifier=OperationIdentifier("invoke13", None, "test_invoke"),
config=config,
)
# Verify custom serialization was used
operation_update = mock_state.create_checkpoint.call_args[1]["operation_update"]
expected_serialized = '{"key": "VALUE", "number": "84", "list": [1, 2, 3]}'
assert operation_update.payload == expected_serialized
def test_suspend_with_optional_resume_delay_with_timeout():
"""Test suspend_with_optional_resume_delay with timeout."""
with pytest.raises(TimedSuspendExecution) as exc_info:
suspend_with_optional_resume_delay("test message", 30)
assert "test message" in str(exc_info.value)
def test_suspend_with_optional_resume_delay_no_timeout():
"""Test suspend_with_optional_resume_delay without timeout."""
with pytest.raises(SuspendExecution) as exc_info:
suspend_with_optional_resume_delay("test message", None)
assert "test message" in str(exc_info.value)
def test_suspend_with_optional_resume_delay_zero_timeout():
"""Test suspend_with_optional_resume_delay with zero timeout."""
with pytest.raises(SuspendExecution) as exc_info:
suspend_with_optional_resume_delay("test message", 0)
assert "test message" in str(exc_info.value)
def test_suspend_with_optional_resume_delay_negative_timeout():
"""Test suspend_with_optional_resume_delay with negative timeout."""
with pytest.raises(SuspendExecution) as exc_info:
suspend_with_optional_resume_delay("test message", -5)
assert "test message" in str(exc_info.value)
@pytest.mark.parametrize("status", [OperationStatus.STARTED, OperationStatus.PENDING])
def test_invoke_handler_with_operation_name(status: OperationStatus):
"""Test invoke_handler uses operation name in logs when available."""
mock_state = Mock(spec=ExecutionState)
mock_state.durable_execution_arn = "test_arn"
operation = Operation(
operation_id="invoke14",
operation_type=OperationType.CHAINED_INVOKE,
status=status,
chained_invoke_details=ChainedInvokeDetails(),
)
mock_result = CheckpointedResult.create_from_operation(operation)
mock_state.get_checkpoint_result.return_value = mock_result
with pytest.raises(SuspendExecution):
invoke_handler(
function_name="test_function",
payload="test_input",
state=mock_state,
operation_identifier=OperationIdentifier("invoke14", None, "named_invoke"),
config=None,
)
@pytest.mark.parametrize("status", [OperationStatus.STARTED, OperationStatus.PENDING])
def test_invoke_handler_without_operation_name(status: OperationStatus):
"""Test invoke_handler uses function name in logs when no operation name."""
mock_state = Mock(spec=ExecutionState)
mock_state.durable_execution_arn = "test_arn"
operation = Operation(
operation_id="invoke15",
operation_type=OperationType.CHAINED_INVOKE,
status=status,
chained_invoke_details=ChainedInvokeDetails(),
)
mock_result = CheckpointedResult.create_from_operation(operation)
mock_state.get_checkpoint_result.return_value = mock_result
with pytest.raises(SuspendExecution):
invoke_handler(
function_name="test_function",
payload="test_input",
state=mock_state,
operation_identifier=OperationIdentifier("invoke15", None, None),
config=None,
)
def test_invoke_handler_with_none_payload():
"""Test invoke_handler when payload is None."""
mock_state = Mock(spec=ExecutionState)
mock_state.durable_execution_arn = "test_arn"
mock_result = CheckpointedResult.create_not_found()
mock_state.get_checkpoint_result.return_value = mock_result
with pytest.raises(SuspendExecution):
invoke_handler(
function_name="test_function",
payload=None,
state=mock_state,
operation_identifier=OperationIdentifier("invoke16", None, "test_invoke"),
config=None,
)
# Verify checkpoint was created with None payload
mock_state.create_checkpoint.assert_called_once()
operation_update = mock_state.create_checkpoint.call_args[1]["operation_update"]
assert operation_update.payload == "null" # JSON serialization of None
def test_invoke_handler_already_succeeded_with_none_payload():
"""Test invoke_handler when operation succeeded and original payload was None."""
mock_state = Mock(spec=ExecutionState)
mock_state.durable_execution_arn = "test_arn"
operation = Operation(
operation_id="invoke17",
operation_type=OperationType.CHAINED_INVOKE,
status=OperationStatus.SUCCEEDED,
chained_invoke_details=ChainedInvokeDetails(result=json.dumps("test_result")),
)
mock_result = CheckpointedResult.create_from_operation(operation)
mock_state.get_checkpoint_result.return_value = mock_result
result = invoke_handler(
function_name="test_function",
payload=None,
state=mock_state,
operation_identifier=OperationIdentifier("invoke17", None, "test_invoke"),
config=None,
)
assert result == "test_result"
mock_state.create_checkpoint.assert_not_called()
@patch(
"aws_durable_execution_sdk_python.operation.invoke.suspend_with_optional_resume_delay"
)
def test_invoke_handler_suspend_does_not_raise(mock_suspend):
"""Test invoke_handler when suspend_with_optional_resume_delay doesn't raise an exception."""
mock_state = Mock(spec=ExecutionState)
mock_state.durable_execution_arn = "test_arn"
mock_result = CheckpointedResult.create_not_found()
mock_state.get_checkpoint_result.return_value = mock_result
# Mock suspend_with_optional_resume_delay to not raise an exception (which it should always do)
mock_suspend.return_value = None
with pytest.raises(
ExecutionError,
match="suspend_with_optional_resume_delay should have raised an exception, but did not.",
):
invoke_handler(
function_name="test_function",
payload="test_input",
state=mock_state,
operation_identifier=OperationIdentifier("invoke18", None, "test_invoke"),
config=None,
)
mock_suspend.assert_called_once()
def test_invoke_handler_with_tenant_id():
"""Test invoke_handler passes tenant_id to checkpoint."""
mock_state = Mock(spec=ExecutionState)
mock_state.durable_execution_arn = "test_arn"
mock_state.get_checkpoint_result.return_value = (
CheckpointedResult.create_not_found()
)
config = InvokeConfig(tenant_id="test-tenant-123")
with pytest.raises(SuspendExecution):
invoke_handler(
function_name="test_function",
payload="test_input",
state=mock_state,
operation_identifier=OperationIdentifier("invoke1", None, None),
config=config,
)
# Verify checkpoint was called with tenant_id
mock_state.create_checkpoint.assert_called_once()
operation_update = mock_state.create_checkpoint.call_args[1]["operation_update"]
chained_invoke_options = operation_update.to_dict()["ChainedInvokeOptions"]
assert chained_invoke_options["FunctionName"] == "test_function"
assert chained_invoke_options["TenantId"] == "test-tenant-123"
def test_invoke_handler_without_tenant_id():
"""Test invoke_handler without tenant_id doesn't include it in checkpoint."""
mock_state = Mock(spec=ExecutionState)
mock_state.durable_execution_arn = "test_arn"
mock_state.get_checkpoint_result.return_value = (
CheckpointedResult.create_not_found()
)
config = InvokeConfig(tenant_id=None)
with pytest.raises(SuspendExecution):
invoke_handler(
function_name="test_function",
payload="test_input",
state=mock_state,
operation_identifier=OperationIdentifier("invoke1", None, None),
config=config,
)
# Verify checkpoint was called without tenant_id
mock_state.create_checkpoint.assert_called_once()
operation_update = mock_state.create_checkpoint.call_args[1]["operation_update"]
chained_invoke_options = operation_update.to_dict()["ChainedInvokeOptions"]
assert chained_invoke_options["FunctionName"] == "test_function"
assert "TenantId" not in chained_invoke_options
def test_invoke_handler_default_config_no_tenant_id():
"""Test invoke_handler with default config has no tenant_id."""
mock_state = Mock(spec=ExecutionState)
mock_state.durable_execution_arn = "test_arn"
mock_state.get_checkpoint_result.return_value = (
CheckpointedResult.create_not_found()
)
with pytest.raises(SuspendExecution):
invoke_handler(
function_name="test_function",
payload="test_input",
state=mock_state,
operation_identifier=OperationIdentifier("invoke1", None, None),
config=None,
)
# Verify checkpoint was called without tenant_id
mock_state.create_checkpoint.assert_called_once()
operation_update = mock_state.create_checkpoint.call_args[1]["operation_update"]
chained_invoke_options = operation_update.to_dict()["ChainedInvokeOptions"]
assert chained_invoke_options["FunctionName"] == "test_function"
assert "TenantId" not in chained_invoke_options
def test_invoke_handler_defaults_to_json_serdes():
"""Test invoke_handler uses DEFAULT_JSON_SERDES when config has no serdes."""
mock_state = Mock(spec=ExecutionState)
mock_state.durable_execution_arn = "test_arn"
mock_state.get_checkpoint_result.return_value = (
CheckpointedResult.create_not_found()
)
config = InvokeConfig[dict, dict](serdes_payload=None, serdes_result=None)
payload = {"key": "value", "number": 42}
with pytest.raises(SuspendExecution):
invoke_handler(
function_name="test_function",
payload=payload,
state=mock_state,
operation_identifier=OperationIdentifier("invoke_json", None, None),
config=config,
)
# Verify JSON serialization was used (not extended types)
operation_update = mock_state.create_checkpoint.call_args[1]["operation_update"]
assert operation_update.payload == json.dumps(payload)
def test_invoke_handler_result_defaults_to_json_serdes():
"""Test invoke_handler uses DEFAULT_JSON_SERDES for result deserialization."""
mock_state = Mock(spec=ExecutionState)
mock_state.durable_execution_arn = "test_arn"
result_data = {"key": "value", "number": 42}
operation = Operation(
operation_id="invoke_result_json",
operation_type=OperationType.CHAINED_INVOKE,
status=OperationStatus.SUCCEEDED,
chained_invoke_details=ChainedInvokeDetails(result=json.dumps(result_data)),
)
mock_result = CheckpointedResult.create_from_operation(operation)
mock_state.get_checkpoint_result.return_value = mock_result
config = InvokeConfig[dict, dict](serdes_payload=None, serdes_result=None)
result = invoke_handler(
function_name="test_function",
payload={"input": "data"},
state=mock_state,
operation_identifier=OperationIdentifier("invoke_result_json", None, None),
config=config,
)
# Verify JSON deserialization was used (not extended types)
assert result == result_data