From 419f3fba5a32d2c77a6e7a89abf347acb4314f5a Mon Sep 17 00:00:00 2001 From: cm-iwata <38879253+cm-iwata@users.noreply.github.com> Date: Wed, 15 Jul 2020 22:01:03 +0900 Subject: [PATCH] fix API Gateway:create_usage_plan_key return wrong status code (#3134) --- moto/apigateway/responses.py | 4 +--- tests/test_apigateway/test_apigateway.py | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/moto/apigateway/responses.py b/moto/apigateway/responses.py index 93ea5d4ff..d8f3ed505 100644 --- a/moto/apigateway/responses.py +++ b/moto/apigateway/responses.py @@ -528,13 +528,11 @@ class APIGatewayResponse(BaseResponse): error.message, error.error_type ), ) - + return 201, {}, json.dumps(usage_plan_response) elif self.method == "GET": usage_plans_response = self.backend.get_usage_plan_keys(usage_plan_id) return 200, {}, json.dumps({"item": usage_plans_response}) - return 200, {}, json.dumps(usage_plan_response) - def usage_plan_key_individual(self, request, full_url, headers): self.setup_class(request, full_url, headers) diff --git a/tests/test_apigateway/test_apigateway.py b/tests/test_apigateway/test_apigateway.py index 756da76e9..d79851ab0 100644 --- a/tests/test_apigateway/test_apigateway.py +++ b/tests/test_apigateway/test_apigateway.py @@ -1989,6 +1989,7 @@ def test_usage_plan_keys(): key_type = "API_KEY" payload = {"usagePlanId": usage_plan_id, "keyId": key_id, "keyType": key_type} response = client.create_usage_plan_key(**payload) + response["ResponseMetadata"]["HTTPStatusCode"].should.equals(201) usage_plan_key_id = response["id"] # Get current plan keys (expect 1)