Skip to content
This repository was archived by the owner on Mar 6, 2025. It is now read-only.

Commit 03f9cc8

Browse files
committed
fix statuscode feature bugging lists returned to json
1 parent c800287 commit 03f9cc8

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lambda_decorators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def handler(event, context):
170170

171171
logger = logging.getLogger(__name__)
172172

173-
__version__ = "0.5.0"
173+
__version__ = "0.5.1"
174174

175175

176176
class LambdaDecorator(object):
@@ -503,7 +503,7 @@ def wrapper_wrapper(handler):
503503
def wrapper(event, context):
504504
try:
505505
resp = handler(event, context)
506-
if resp is not None:
506+
if isinstance(resp, dict):
507507
status = resp.pop('statusCode', 200)
508508
else:
509509
status = 200

tests/test_json_http_resp.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,9 @@ def test_json_http_resp_w_status_code():
5151
def hello(example, context):
5252
return {'foo': 'bar', 'statusCode': 403}
5353
assert hello({}, MagicMock()) == {"statusCode": 403, "body": '{"foo": "bar"}'}
54+
55+
def test_json_http_resp_w_list():
56+
@json_http_resp
57+
def hello(example, context):
58+
return [2,4,6]
59+
assert hello({}, MagicMock()) == {"statusCode": 200, "body": '[2, 4, 6]'}

0 commit comments

Comments
 (0)