From c37ddd9c5cbef54e6d0c6ece0df7e50b8c7b593d Mon Sep 17 00:00:00 2001 From: Sha Date: Tue, 12 Sep 2023 21:16:42 +0800 Subject: [PATCH] Core responses: Add missing registered() (#6597) --- moto/core/responses_custom_registry.py | 7 +++++++ tests/test_apigateway/test_apigateway_integration.py | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/moto/core/responses_custom_registry.py b/moto/core/responses_custom_registry.py index b4642e852..3de222fe7 100644 --- a/moto/core/responses_custom_registry.py +++ b/moto/core/responses_custom_registry.py @@ -17,6 +17,13 @@ class CustomRegistry(responses.registries.FirstMatchRegistry): def __init__(self) -> None: self._registered: Dict[str, List[responses.BaseResponse]] = defaultdict(list) + @property + def registered(self) -> List[responses.BaseResponse]: + res = [] + for resps in self._registered.values(): + res += resps + return res + def add(self, response: responses.BaseResponse) -> responses.BaseResponse: if response not in self._registered[response.method]: self._registered[response.method].append(response) diff --git a/tests/test_apigateway/test_apigateway_integration.py b/tests/test_apigateway/test_apigateway_integration.py index 87a17c631..ae44bf078 100644 --- a/tests/test_apigateway/test_apigateway_integration.py +++ b/tests/test_apigateway/test_apigateway_integration.py @@ -15,7 +15,8 @@ def test_http_integration(): responses_mock.add( responses_mock.GET, "http://httpbin.org/robots.txt", body="a fake response" ) - + registered = responses_mock.registered() + assert isinstance(registered, list) and len(registered) > 1 region_name = "us-west-2" client = boto3.client("apigateway", region_name=region_name) response = client.create_rest_api(name="my_api", description="this is my api")