Skip to content

Commit 9914ab5

Browse files
Adding custom serializer
1 parent 214d061 commit 9914ab5

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

tests/functional/event_handler/required_dependencies/test_bedrock_agent_functions.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ def decimal_serializer(obj):
441441
@app.tool()
442442
def decimal_response():
443443
# Return a response with Decimal type that standard JSON can't serialize
444-
return {"price": decimal.Decimal("99.99")}
444+
return {"price": round(decimal.Decimal("99"))}
445445

446446
# WHEN calling with a response containing non-standard JSON types
447447
raw_event = load_event("bedrockAgentFunctionEvent.json")
@@ -450,7 +450,6 @@ def decimal_response():
450450

451451
# THEN non-standard types should be properly serialized
452452
response_body = result["response"]["functionResponse"]["responseBody"]["TEXT"]["body"]
453-
parsed_response = json.loads(response_body)
454453

455454
# VERIFY that decimal was converted to float and datetime to ISO string
456-
assert parsed_response["price"] == 99.99
455+
assert response_body == json.dumps({"price": 99})

0 commit comments

Comments
 (0)