def callback(request, name): if request.url.host == "foo.bar" and request.content == b'{"foo": "bar"}': return respx.MockResponse( 202, headers={"X-Foo": "bar"}, text=f"hello {name}", http_version="HTTP/2", ) return httpx.Response(404)
def content_callback(request, slug): content = jsonlib.loads(request.content) return respx.MockResponse(text=f"hello {slug}{content['x']}")