Repository: getsentry/responses

Issue:
Facilitate how to view the registered responses for debugging purposes
<!--
Please provide some context on what problem you are trying to solve and how this feature is going to help.

-->
Hi maintainers! This is my first issue and intent to help here 😄 

## Motivation
When writing my tests and debugging them, sometimes I want to know which are the registered responses so far since we tend to use different fixtures to add responses and we lose track of which are the URLs expected to be called before the test ends.

The documentation says that in order to get some access to them we should access them via `responses.mock._matches` which in turn, it will return the list of `Response` objects and we have to access them to have information such as the precious URL, as in:
```
[
    <responses.Response object at 0x10a121670>,
    <responses.Response object at 0x10a1216a0>,
    <responses.Response object at 0x10a1216d0>
]
```

## Suggestion
To have a method that facilitates retrieving information of which are these registered responses.

I'd suggest something like `responses.mock.show_registered(urls_only: bool = False)` and return a list of the URLs registered if `urls_only == True` or a dictionary structure nested by `method` and `url`.
For example having:
```
responses.add(
    responses.GET, "http://example.com/", body="", headers={"X-Test": "foo"}
)
responses.add(
    responses.GET, "http://example.com/", body="", headers={"X-Test": "foo"}
)
responses.add(
    responses.POST, "http://anotherdomain.com/", body={"field": "value"}
)
```
then calling `responses.mock.show_registered(urls_only=True)` would return:
```
["http://example.com/", "http://example.com/", "http://anotherdomain.com/" ]
```
or by calling just `responses.mock.show_registered()` would return:
```
{
    'GET': {
        'http://example.com/': [
            {
                'body': '',
                'content_type': 'text/plain',
                'headers': {'X-Test': 'foo'},
                'status': 200
            },
            {
                'body': '',
                'content_type': 'text/plain',
                'headers': {'X-Test': 'foo'},
                'status': 200
            }
        ]
    },
    'POST': {
        'http://anotherdomain.com/': [
            {
                'body': {'field': 'value'},
                'content_type': 'text/plain',
                'headers': None,
                'status': 200
            }
        ]
    }
}
```

## Implementation
I have already implemented this in a local branch, if you think it could be useful I can create a Pull Request for you to review it and give me some feedback.



Comments:

Patch:
diff --git a/README.rst b/README.rst
index 1bfa062..20f5f27 100644
--- a/README.rst
+++ b/README.rst
@@ -475,9 +475,9 @@ Regex can be used like:
 Viewing/Modifying registered responses
 --------------------------------------
 
-Registered responses are available as a private attribute of the RequestMock
+Registered responses are available as a public method of the RequestMock
 instance. It is sometimes useful for debugging purposes to view the stack of
-registered responses which can be accessed via ``responses.mock._matches``.
+registered responses which can be accessed via ``responses.registered()``.
 
 The ``replace`` function allows a previously registered ``response`` to be
 changed. The method signature is identical to ``add``. ``response`` s are
diff --git a/responses/__init__.py b/responses/__init__.py
index 7e4a6e5..3eb9399 100644
--- a/responses/__init__.py
+++ b/responses/__init__.py
@@ -418,6 +418,17 @@ class Response(BaseResponse):
             preload_content=False,
         )
 
+    def __repr__(self):
+        return (
+            "<Response(url='{url}' status={status} "
+            "content_type='{content_type}' headers='{headers}')>".format(
+                url=self.url,
+                status=self.status,
+                content_type=self.content_type,
+                headers=json_module.dumps(self.headers),
+            )
+        )
+
 
 class CallbackResponse(BaseResponse):
     def __init__(
@@ -651,6 +662,9 @@ class RequestsMock(object):
             )
         )
 
+    def registered(self):
+        return self._matches
+
     @property
     def calls(self):
         return self._calls
@@ -809,6 +823,7 @@ __all__ = [
     "PATCH",
     "POST",
     "PUT",
+    "registered",
     "remove",
     "replace",
     "reset",
@@ -834,6 +849,7 @@ passthru_prefixes = _default_mock.passthru_prefixes
 PATCH = _default_mock.PATCH
 POST = _default_mock.POST
 PUT = _default_mock.PUT
+registered = _default_mock.registered
 remove = _default_mock.remove
 replace = _default_mock.replace
 reset = _default_mock.reset
diff --git a/responses/__init__.pyi b/responses/__init__.pyi
index 92ad071..b437a34 100644
--- a/responses/__init__.pyi
+++ b/responses/__init__.pyi
@@ -175,6 +175,7 @@ class RequestsMock:
     def start(self) -> None: ...
     def stop(self, allow_assert: bool = ...) -> None: ...
     def assert_call_count(self, url: str, count: int) -> bool: ...
+    def registered(self) -> List[Any]: ...
 
 _F = TypeVar("_F", bound=Callable[..., Any])
 
@@ -251,6 +252,10 @@ class _Upsert(Protocol):
         match: List[Any] = ...,
     ) -> None: ...
 
+class _Registered(Protocol):
+    def __call__(self) -> List[Response]: ...
+
+
 activate: _Activate
 add: _Add
 add_callback: _AddCallback
@@ -268,6 +273,7 @@ passthru_prefixes: Tuple[str, ...]
 PATCH: Literal["PATCH"]
 POST: Literal["POST"]
 PUT: Literal["PUT"]
+registered: _Registered
 remove: _Remove
 replace: _Replace
 reset: Callable[[], None]
@@ -297,6 +303,7 @@ __all__ = [
     "PATCH",
     "POST",
     "PUT",
+    "registered",
     "remove",
     "replace",
     "reset",


Test patch:
diff --git a/responses/test_responses.py b/responses/test_responses.py
index fdab8da..6ab8606 100644
--- a/responses/test_responses.py
+++ b/responses/test_responses.py
@@ -1397,3 +1397,78 @@ def test_fail_request_error():
 
     run()
     assert_reset()
+
+
+@pytest.mark.parametrize(
+    "response_params, expected_representation",
+    [
+        (
+            {"method": responses.GET, "url": "http://example.com/"},
+            (
+                "<Response(url='http://example.com/' status=200 "
+                "content_type='text/plain' headers='null')>"
+            ),
+        ),
+        (
+            {
+                "method": responses.POST,
+                "url": "http://another-domain.com/",
+                "content_type": "application/json",
+                "status": 404,
+            },
+            (
+                "<Response(url='http://another-domain.com/' status=404 "
+                "content_type='application/json' headers='null')>"
+            ),
+        ),
+        (
+            {
+                "method": responses.PUT,
+                "url": "http://abcd.com/",
+                "content_type": "text/html",
+                "status": 500,
+                "headers": {"X-Test": "foo"},
+                "body": {"it_wont_be": "considered"},
+            },
+            (
+                "<Response(url='http://abcd.com/' status=500 "
+                "content_type='text/html' headers='{\"X-Test\": \"foo\"}')>"
+            ),
+        ),
+    ],
+)
+def test_response_representations(response_params, expected_representation):
+    response = Response(**response_params)
+
+    assert str(response) == expected_representation
+    assert repr(response) == expected_representation
+
+
+def test_mocked_responses_list_registered():
+    @responses.activate
+    def run():
+        first_response = Response(
+            responses.GET,
+            "http://example.com/",
+            body="",
+            headers={"X-Test": "foo"},
+            status=404,
+        )
+        second_response = Response(
+            responses.GET, "http://example.com/", body="", headers={"X-Test": "foo"}
+        )
+        third_response = Response(
+            responses.POST,
+            "http://anotherdomain.com/",
+        )
+        responses.add(first_response)
+        responses.add(second_response)
+        responses.add(third_response)
+
+        mocks_list = responses.registered()
+
+        assert mocks_list == responses.mock._matches
+        assert mocks_list == [first_response, second_response, third_response]
+
+    run()
+    assert_reset()