Skip to content

Commit

Permalink
Add Call.has_response() helper
Browse files Browse the repository at this point in the history
  • Loading branch information
lundberg committed Sep 16, 2022
1 parent a2f0e48 commit 9aa3f76
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions respx/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ def response(self) -> httpx.Response:
raise ValueError(f"{self!r} has no response")
return self.optional_response

def has_response(self) -> bool:
return self.optional_response is not None


class CallList(list, mock.NonCallableMock):
def __init__(self, *args: Sequence[Call], name: Any = "respx") -> None:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_remote_pass_through(using, client_lib, call_count): # pragma: nocover
assert response.json()["json"] == {"foo": "bar"}

assert respx_mock.calls.last.request.url == url
assert respx_mock.calls.last.response == None # noqa: E711
assert respx_mock.calls.last.has_response() is False

assert route.call_count == call_count
assert respx_mock.calls.call_count == call_count

0 comments on commit 9aa3f76

Please sign in to comment.