Closed commentator8 closed 11 months ago
I am not sure if the way i was writing was correct
Not exactly .. the path
pattern (kwarg) is for the path bit of the url that you want to match on.
To match full url with .route()
you should use the url pattern, e.g.
url = 'https://www.instance_url.com/oauth_token.do'
my_route = respx.route(method="POST", url=url)
response = await httpx.post(url)```
Hi,
i used to write something like this:
and due to the change in 0.20.2 (it worked in 0.20.1) where you now filter based on a white list that doesn't include
:
, the above will break (due to the https:) withrespx.models.AllMockedAssertionError: RESPX: <Request('POST', 'https://www.instance_url.com/oauth_token.do')> not mocked!
The below however will work:
I am not sure if the way i was writing was correct, but in any case it was a naive take and I imagine others could get caught in this as well. The docs show the below as the quickstart for the non route version (e.g.
respx.get("https://foo.bar/").mock(return_value=Response(204))
) and for the route give a host=a, path=b example.