Skip to content

Commit 873ddb4

Browse files
add docstrings to OrderedRegistry (#587)
Add docstrings to OrderedRegistry Co-authored-by: Mark Story <[email protected]>
1 parent 240504c commit 873ddb4

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

responses/registries.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,32 @@ def replace(self, response: "BaseResponse") -> "BaseResponse":
7575

7676

7777
class OrderedRegistry(FirstMatchRegistry):
78+
"""Registry where `Response` objects are dependent on the insertion order and invocation index.
79+
80+
OrderedRegistry applies the rule of first in - first out. Responses should be invoked in
81+
the same order in which they were added to the registry. Otherwise, an error is returned.
82+
"""
83+
7884
def find(
7985
self, request: "PreparedRequest"
8086
) -> Tuple[Optional["BaseResponse"], List[str]]:
87+
"""Find the next registered `Response` and check if it matches the request.
88+
89+
Search is performed by taking the first element of the registered responses list
90+
and removing this object (popping from the list).
91+
92+
Parameters
93+
----------
94+
request : PreparedRequest
95+
Request that was caught by the custom adapter.
96+
97+
Returns
98+
-------
99+
Tuple[Optional["BaseResponse"], List[str]]
100+
Matched `Response` object and empty list in case of match.
101+
Otherwise, None and a list with reasons for not finding a match.
102+
103+
"""
81104

82105
if not self.registered:
83106
return None, ["No more registered responses"]

0 commit comments

Comments
 (0)