Skip to content

Commit ca6dd11

Browse files
committed
chore: add validation error test
1 parent a9a220e commit ca6dd11

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/functional/event_handler/test_bedrock_agent.py

+23
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,29 @@ def claims():
7979
assert result["response"]["httpStatusCode"] == 404
8080

8181

82+
def test_bedrock_agent_event_with_validation_error():
83+
# GIVEN a Bedrock Agent event
84+
app = BedrockAgentResolver()
85+
86+
@app.get("/claims")
87+
def claims() -> Dict[str, Any]:
88+
return "oh no, this is not a dict" # type: ignore
89+
90+
# WHEN calling the event handler
91+
result = app(load_event("bedrockAgentEvent.json"), {})
92+
93+
# THEN process event correctly
94+
# AND set the current_event type as BedrockAgentEvent
95+
assert result["messageVersion"] == "1.0"
96+
assert result["response"]["apiPath"] == "/claims"
97+
assert result["response"]["actionGroup"] == "ClaimManagementActionGroup"
98+
assert result["response"]["httpMethod"] == "GET"
99+
assert result["response"]["httpStatusCode"] == 422
100+
101+
body = result["response"]["responseBody"]["application/json"]["body"]
102+
assert "value is not a valid dict" in body
103+
104+
82105
def test_bedrock_agent_event_with_exception():
83106
# GIVEN a Bedrock Agent event
84107
app = BedrockAgentResolver()

0 commit comments

Comments
 (0)