Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3004b16

Browse files
committed
Add test for invalid state machine definition in test state call
Ignoring the exact validation message for now
1 parent4417e3b commit3004b16

File tree

5 files changed

+69
-0
lines changed

5 files changed

+69
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"Comment":"Base state machine with a state that is not a valid state definition.",
3+
"StartAt":"ExistingButInvalidState",
4+
"States":{
5+
"ExistingButInvalidState":{
6+
"Type":"TypeThatDoesNotExist",
7+
"End":true
8+
}
9+
}
10+
}

‎tests/aws/services/stepfunctions/templates/test_state/test_state_templates.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,7 @@ class TestStateMachineTemplate(TemplateLoader):
124124
LOCALSTACK_BLOGPOST_SCENARIO_STATE_MACHINE:Final[str]=os.path.join(
125125
_THIS_FOLDER,"statemachines/localstack_blogpost_scenario_state_machine.json5"
126126
)
127+
128+
BASE_INVALID_STATE_DEFINITION:Final[str]=os.path.join(
129+
_THIS_FOLDER,"statemachines/base_invalid_state_definition.json5"
130+
)

‎tests/aws/services/stepfunctions/v2/test_state/test_test_state_machine_scenarios.py‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,33 @@ def test_base_state_name_validation_failures(
125125
sfn_snapshot.match(
126126
"exception", {"exception_typename":ex.typename,"exception_value":ex.value}
127127
)
128+
129+
@markers.aws.validated
130+
@markers.snapshot.skip_snapshot_verify(paths=["$..Error.Message","$..message"])
131+
# ANTLR parser message has different wording but the same meaning as AWS response. Not investing time now to convert to the exact same wording - relying on error code for test.
132+
# TODO match wording and hide implementation details (ANTLR)
133+
# expected:
134+
# /Error/Message "Invalid State Machine Definition: 'SCHEMA_VALIDATION_FAILED: The field 'Type' should have one of these values: [Task, Wait, Pass, Succeed, Fail, Choice, Parallel, Map] at /States/ExistingButInvalidState/Type'"
135+
# actual:
136+
# 'ASLParserException line 1:170, at "TypeThatDoesNotExist", mismatched input \'"TypeThatDoesNotExist"\' expecting {\'"Task"\', \'"Choice"\', \'"Fail"\', \'"Succeed"\', \'"Pass"\', \'"Wait"\', \'"Parallel"\', \'"Map"\'}'
137+
deftest_state_name_invalid_state_definition(
138+
self,
139+
aws_client,
140+
aws_client_no_sync_prefix,
141+
create_state_machine_iam_role,
142+
sfn_snapshot,
143+
):
144+
sfn_role_arn=create_state_machine_iam_role(aws_client)
145+
146+
template=TSMT.load_sfn_template(TSMT.BASE_INVALID_STATE_DEFINITION)
147+
definition=json.dumps(template)
148+
149+
withpytest.raises(Exception)ase:
150+
aws_client_no_sync_prefix.stepfunctions.test_state(
151+
stateName="ExistingButInvalidState",
152+
definition=definition,
153+
roleArn=sfn_role_arn,
154+
input=HELLO_WORLD_INPUT,
155+
inspectionLevel=InspectionLevel.INFO,
156+
)
157+
sfn_snapshot.match("validation_exception",e.value.response)

‎tests/aws/services/stepfunctions/v2/test_state/test_test_state_machine_scenarios.snapshot.json‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,5 +345,21 @@
345345
}
346346
}
347347
}
348+
},
349+
"tests/aws/services/stepfunctions/v2/test_state/test_test_state_machine_scenarios.py::TestStateMachineScenarios::test_state_name_invalid_state_definition": {
350+
"recorded-date":"01-12-2025, 16:53:01",
351+
"recorded-content": {
352+
"validation_exception": {
353+
"Error": {
354+
"Code":"InvalidDefinition",
355+
"Message":"Invalid State Machine Definition: 'SCHEMA_VALIDATION_FAILED: The field 'Type' should have one of these values: [Task, Wait, Pass, Succeed, Fail, Choice, Parallel, Map] at /States/ExistingButInvalidState/Type'"
356+
},
357+
"message":"Invalid State Machine Definition: 'SCHEMA_VALIDATION_FAILED: The field 'Type' should have one of these values: [Task, Wait, Pass, Succeed, Fail, Choice, Parallel, Map] at /States/ExistingButInvalidState/Type'",
358+
"ResponseMetadata": {
359+
"HTTPHeaders": {},
360+
"HTTPStatusCode":400
361+
}
362+
}
363+
}
348364
}
349365
}

‎tests/aws/services/stepfunctions/v2/test_state/test_test_state_machine_scenarios.validation.json‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,5 +160,14 @@
160160
"teardown":1.91,
161161
"total":14.58
162162
}
163+
},
164+
"tests/aws/services/stepfunctions/v2/test_state/test_test_state_machine_scenarios.py::TestStateMachineScenarios::test_state_name_invalid_state_definition": {
165+
"last_validated_date":"2025-12-01T16:53:03+00:00",
166+
"durations_in_seconds": {
167+
"setup":0.52,
168+
"call":14.29,
169+
"teardown":1.13,
170+
"total":15.94
171+
}
163172
}
164173
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp