From 5ba786d97a0ba516d7c609991c1f403f865e4acc Mon Sep 17 00:00:00 2001 From: Andrey Kislyuk Date: Wed, 22 Jan 2020 16:39:11 -0800 Subject: [PATCH 1/2] awslambda: return actual result in sync invoke Return actual output of the Lambda instead of echoing the input. --- moto/awslambda/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moto/awslambda/models.py b/moto/awslambda/models.py index 38ff81fb2..8d11a5832 100644 --- a/moto/awslambda/models.py +++ b/moto/awslambda/models.py @@ -472,7 +472,7 @@ class LambdaFunction(BaseModel): payload["result"] = response_headers["x-amz-log-result"] result = res.encode("utf-8") else: - result = json.dumps(payload) + result = res if errored: response_headers["x-amz-function-error"] = "Handled" From 324ef5af36abe9898bfbe7ed30af376b6e4d6d59 Mon Sep 17 00:00:00 2001 From: Andrey Kislyuk Date: Fri, 24 Jan 2020 16:11:44 +0000 Subject: [PATCH 2/2] Fix test --- tests/test_awslambda/test_lambda.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_awslambda/test_lambda.py b/tests/test_awslambda/test_lambda.py index 2835729f8..9830f697f 100644 --- a/tests/test_awslambda/test_lambda.py +++ b/tests/test_awslambda/test_lambda.py @@ -148,7 +148,7 @@ def test_invoke_event_function(): FunctionName="testFunction", InvocationType="Event", Payload=json.dumps(in_data) ) success_result["StatusCode"].should.equal(202) - json.loads(success_result["Payload"].read().decode("utf-8")).should.equal({}) + json.loads(success_result["Payload"].read().decode("utf-8")).should.equal(in_data) if settings.TEST_SERVER_MODE: