From 11ff548d147c88727b2858b2ebc730e09899f228 Mon Sep 17 00:00:00 2001 From: Tomoya Iwata Date: Sun, 17 Mar 2019 17:54:34 +0900 Subject: [PATCH] fix #2113 moto must return Http status code 201 when lambda publish_version has succeeded --- moto/awslambda/responses.py | 2 +- tests/test_awslambda/test_lambda.py | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/moto/awslambda/responses.py b/moto/awslambda/responses.py index d4eb73bc3..1c43ef84b 100644 --- a/moto/awslambda/responses.py +++ b/moto/awslambda/responses.py @@ -183,7 +183,7 @@ class LambdaResponse(BaseResponse): fn = self.lambda_backend.publish_function(function_name) if fn: config = fn.get_configuration() - return 200, {}, json.dumps(config) + return 201, {}, json.dumps(config) else: return 404, {}, "{}" diff --git a/tests/test_awslambda/test_lambda.py b/tests/test_awslambda/test_lambda.py index 7f3b44b79..34fd9c9b3 100644 --- a/tests/test_awslambda/test_lambda.py +++ b/tests/test_awslambda/test_lambda.py @@ -4,6 +4,7 @@ import base64 import botocore.client import boto3 import hashlib +from http import HTTPStatus import io import json import time @@ -471,7 +472,8 @@ def test_publish(): function_list['Functions'].should.have.length_of(1) latest_arn = function_list['Functions'][0]['FunctionArn'] - conn.publish_version(FunctionName='testFunction') + res = conn.publish_version(FunctionName='testFunction') + assert res['ResponseMetadata']['HTTPStatusCode'] == HTTPStatus.CREATED function_list = conn.list_functions() function_list['Functions'].should.have.length_of(2) @@ -853,8 +855,8 @@ def test_list_versions_by_function(): Publish=True, ) - conn.publish_version(FunctionName='testFunction') - + res = conn.publish_version(FunctionName='testFunction') + assert res['ResponseMetadata']['HTTPStatusCode'] == HTTPStatus.CREATED versions = conn.list_versions_by_function(FunctionName='testFunction') assert versions['Versions'][0]['FunctionArn'] == 'arn:aws:lambda:us-west-2:123456789012:function:testFunction:$LATEST'