Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.

Commit 06e17a7

Browse files
committed
Add test for empty variables dict passed as param
1 parent b80b5ea commit 06e17a7

File tree

3 files changed

+112
-13
lines changed

3 files changed

+112
-13
lines changed

tests/aws/services/stepfunctions/v2/test_state/test_test_state_scenarios.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,21 @@ def test_localstack_blogpost_scenario(
417417
)
418418
sfn_snapshot.match("check_approval_denied_response", check_approval_denied_response)
419419

420+
TEMPLATES_VARIABLES = [
421+
pytest.param(
422+
(
423+
OT.BASE_EXPR,
424+
{
425+
"var_input_value": "test_value",
426+
"var_constant_1": 10,
427+
},
428+
),
429+
id="base_expressions",
430+
),
431+
pytest.param((OT.BASE_LITERALS, {}), id="empty_variables"),
432+
]
433+
434+
@pytest.mark.parametrize("templates_variables", TEMPLATES_VARIABLES)
420435
@markers.aws.validated
421436
@markers.snapshot.skip_snapshot_verify(
422437
paths=[
@@ -428,21 +443,19 @@ def test_state_with_variables(
428443
self,
429444
aws_client_no_sync_prefix,
430445
sfn_snapshot,
446+
templates_variables,
431447
):
432448
sfn_snapshot.add_transformer(
433449
sfn_snapshot.transform.key_value("RoleArn", "role-arn", reference_replacement=False)
434450
) # roleArn is null in AWS but is not null in LocalStack, see comment in provider implementation. If this transformer is not added then roleArn is picked up as another resource name in LocalStack, causing resource placeholders mismatch, e.g. <resource:3> where <resource:2> is expected.
435451
sfn_snapshot.add_transformer(sfn_snapshot.transform.resource_name())
436-
template = OT.load_sfn_template(OT.BASE_EXPR)
452+
template_path, variables_raw = templates_variables
453+
template = OT.load_sfn_template(template_path)
454+
437455
definition = json.dumps(template)
438456

439457
exec_input = json.dumps({"input_values": [1, 2, 3]})
440-
variables = json.dumps(
441-
{
442-
"var_input_value": "test_value",
443-
"var_constant_1": 10,
444-
}
445-
)
458+
variables = json.dumps(variables_raw)
446459

447460
test_case_response = aws_client_no_sync_prefix.stepfunctions.test_state(
448461
definition=definition,

tests/aws/services/stepfunctions/v2/test_state/test_test_state_scenarios.snapshot.json

Lines changed: 79 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2235,8 +2235,8 @@
22352235
}
22362236
}
22372237
},
2238-
"tests/aws/services/stepfunctions/v2/test_state/test_test_state_scenarios.py::TestStateCaseScenarios::test_state_with_variables": {
2239-
"recorded-date": "23-02-2026, 12:08:28",
2238+
"tests/aws/services/stepfunctions/v2/test_state/test_test_state_scenarios.py::TestStateCaseScenarios::test_state_with_variables[base_expressions]": {
2239+
"recorded-date": "24-02-2026, 11:15:19",
22402240
"recorded-content": {
22412241
"test_case_response": {
22422242
"inspectionData": {
@@ -2293,5 +2293,82 @@
22932293
}
22942294
}
22952295
}
2296+
},
2297+
"tests/aws/services/stepfunctions/v2/test_state/test_test_state_scenarios.py::TestStateCaseScenarios::test_state_with_variables[empty_variables]": {
2298+
"recorded-date": "24-02-2026, 11:15:19",
2299+
"recorded-content": {
2300+
"test_case_response": {
2301+
"inspectionData": {
2302+
"input": {
2303+
"input_values": [
2304+
1,
2305+
2,
2306+
3
2307+
]
2308+
}
2309+
},
2310+
"output": {
2311+
"constant_null": null,
2312+
"constant_int": 0,
2313+
"constant_float": 0.1,
2314+
"constant_bool": true,
2315+
"constant_str": "constant string",
2316+
"constant_not_jsonata": " {% states.input %} ",
2317+
"constant_varpath_states": "$states.input",
2318+
"constant_varpath": "$no.such.var.path",
2319+
"constant_jp_input": "$",
2320+
"constant_jp_input.$": "$",
2321+
"constant_jp_input_path": "$.input_value",
2322+
"constant_jp_context": "$$",
2323+
"constant_if": "States.Format('Format:{}', 101)",
2324+
"constant_lst_empty": [],
2325+
"constant_lst": [
2326+
null,
2327+
0,
2328+
0.1,
2329+
true,
2330+
[],
2331+
{
2332+
"constant": 0
2333+
},
2334+
" {% states.input %} ",
2335+
"$states.input",
2336+
"$no.such.var.path"
2337+
],
2338+
"constant_obj_empty": {},
2339+
"constant_obj": {
2340+
"in_obj_constant_null": null,
2341+
"in_obj_constant_int": 0,
2342+
"in_obj_constant_float": 0.1,
2343+
"in_obj_constant_bool": true,
2344+
"in_obj_constant_str": "constant string",
2345+
"in_obj_constant_not_jsonata": " {% states.input %} ",
2346+
"in_obj_constant_lst_empty": [],
2347+
"in_obj_constant_lst": [
2348+
null,
2349+
0,
2350+
0.1,
2351+
true,
2352+
[],
2353+
{
2354+
"constant": 0
2355+
},
2356+
" {% states.input %} ",
2357+
"$states.input",
2358+
"$no.such.var.path"
2359+
],
2360+
"in_obj_constant_obj_empty": {},
2361+
"in_obj_constant_obj": {
2362+
"constant": 0
2363+
}
2364+
}
2365+
},
2366+
"status": "SUCCEEDED",
2367+
"ResponseMetadata": {
2368+
"HTTPHeaders": {},
2369+
"HTTPStatusCode": 200
2370+
}
2371+
}
2372+
}
22962373
}
22972374
}

tests/aws/services/stepfunctions/v2/test_state/test_test_state_scenarios.validation.json

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -395,13 +395,22 @@
395395
"total": 14.91
396396
}
397397
},
398-
"tests/aws/services/stepfunctions/v2/test_state/test_test_state_scenarios.py::TestStateCaseScenarios::test_state_with_variables": {
399-
"last_validated_date": "2026-02-23T12:08:28+00:00",
398+
"tests/aws/services/stepfunctions/v2/test_state/test_test_state_scenarios.py::TestStateCaseScenarios::test_state_with_variables[base_expressions]": {
399+
"last_validated_date": "2026-02-24T11:15:19+00:00",
400400
"durations_in_seconds": {
401-
"setup": 0.51,
401+
"setup": 0.49,
402402
"call": 0.63,
403403
"teardown": 0.0,
404-
"total": 1.14
404+
"total": 1.12
405+
}
406+
},
407+
"tests/aws/services/stepfunctions/v2/test_state/test_test_state_scenarios.py::TestStateCaseScenarios::test_state_with_variables[empty_variables]": {
408+
"last_validated_date": "2026-02-24T11:15:19+00:00",
409+
"durations_in_seconds": {
410+
"setup": 0.0,
411+
"call": 0.22,
412+
"teardown": 0.0,
413+
"total": 0.22
405414
}
406415
}
407416
}

0 commit comments

Comments
 (0)