Skip to content

Commit 0ee16fd

Browse files
committed
fix: rolled back test changes
1 parent 618bc3e commit 0ee16fd

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

aws_lambda_powertools/event_handler/bedrock_agent.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def build(self, event: BedrockAgentEvent, *args) -> Dict[str, Any]:
2424
self._route(event, None)
2525

2626
body = self.response.body
27-
if self.response.is_json():
27+
if self.response.is_json() and not isinstance(self.response.body, str):
2828
body = self.serializer(self.response.body)
2929

3030
return {

tests/functional/event_handler/test_api_gateway.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ def test_override_route_compress_parameter():
367367
# AND the Response object with compress=False
368368
app = ApiGatewayResolver()
369369
mock_event = {"path": "/my/request", "httpMethod": "GET", "headers": {"Accept-Encoding": "deflate, gzip"}}
370-
expected_value = {"test": "value"}
370+
expected_value = '{"test": "value"}'
371371

372372
@app.get("/my/request", compress=True)
373373
def with_compression() -> Response:
@@ -381,7 +381,7 @@ def handler(event, context):
381381

382382
# THEN the response is not compressed
383383
assert result["isBase64Encoded"] is False
384-
assert json.loads(result["body"]) == expected_value
384+
assert result["body"] == expected_value
385385
assert result["multiValueHeaders"].get("Content-Encoding") is None
386386

387387

@@ -1778,11 +1778,11 @@ def test_route_match_prioritize_full_match():
17781778

17791779
@router.get("/my/{path}")
17801780
def dynamic_handler() -> Response:
1781-
return Response(200, content_types.APPLICATION_JSON, {"hello": "dynamic"})
1781+
return Response(200, content_types.APPLICATION_JSON, json.dumps({"hello": "dynamic"}))
17821782

17831783
@router.get("/my/path")
17841784
def static_handler() -> Response:
1785-
return Response(200, content_types.APPLICATION_JSON, {"hello": "static"})
1785+
return Response(200, content_types.APPLICATION_JSON, json.dumps({"hello": "static"}))
17861786

17871787
app.include_router(router)
17881788

0 commit comments

Comments
 (0)