Core responses: Add missing registered() (#6597)
This commit is contained in:
		
							parent
							
								
									0b8581ae98
								
							
						
					
					
						commit
						c37ddd9c5c
					
				@ -17,6 +17,13 @@ class CustomRegistry(responses.registries.FirstMatchRegistry):
 | 
				
			|||||||
    def __init__(self) -> None:
 | 
					    def __init__(self) -> None:
 | 
				
			||||||
        self._registered: Dict[str, List[responses.BaseResponse]] = defaultdict(list)
 | 
					        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:
 | 
					    def add(self, response: responses.BaseResponse) -> responses.BaseResponse:
 | 
				
			||||||
        if response not in self._registered[response.method]:
 | 
					        if response not in self._registered[response.method]:
 | 
				
			||||||
            self._registered[response.method].append(response)
 | 
					            self._registered[response.method].append(response)
 | 
				
			||||||
 | 
				
			|||||||
@ -15,7 +15,8 @@ def test_http_integration():
 | 
				
			|||||||
    responses_mock.add(
 | 
					    responses_mock.add(
 | 
				
			||||||
        responses_mock.GET, "http://httpbin.org/robots.txt", body="a fake response"
 | 
					        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"
 | 
					    region_name = "us-west-2"
 | 
				
			||||||
    client = boto3.client("apigateway", region_name=region_name)
 | 
					    client = boto3.client("apigateway", region_name=region_name)
 | 
				
			||||||
    response = client.create_rest_api(name="my_api", description="this is my api")
 | 
					    response = client.create_rest_api(name="my_api", description="this is my api")
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user