Skip to content

Commit 45f85f6

Browse files
committed
add test for required fields
1 parent 24978cb commit 45f85f6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/functional/event_handler/required_dependencies/test_bedrock_agent_functions.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,21 @@ def test_bedrock_agent_function_invalid_event():
114114
# WHEN calling with invalid event
115115
with pytest.raises(ValueError, match="Missing required field"):
116116
app.resolve({}, {})
117+
118+
119+
def test_resolve_raises_value_error_on_missing_required_field():
120+
"""Test that resolve() raises ValueError when a required field is missing from the event"""
121+
# GIVEN a Bedrock Agent Function resolver and an incomplete event
122+
resolver = BedrockAgentFunctionResolver()
123+
incomplete_event = {
124+
"messageVersion": "1.0",
125+
"agent": {"alias": "PROD", "name": "hr-assistant-function-def", "version": "1", "id": "1234abcd"},
126+
"sessionId": "123456789123458",
127+
}
128+
129+
# WHEN calling resolve with the incomplete event
130+
# THEN a ValueError is raised with information about the missing field
131+
with pytest.raises(ValueError) as excinfo:
132+
resolver.resolve(incomplete_event, {})
133+
134+
assert "Missing required field:" in str(excinfo.value)

0 commit comments

Comments
 (0)