MCPcopy
hub / github.com/encode/starlette / test_request_url

Function test_request_url

tests/test_requests.py:17–29  ·  view source on GitHub ↗
(test_client_factory: TestClientFactory)

Source from the content-addressed store, hash-verified

15
16
17def test_request_url(test_client_factory: TestClientFactory) -> None:
18 async def app(scope: Scope, receive: Receive, send: Send) -> None:
19 request = Request(scope, receive)
20 data = {"method": request.method, "url": str(request.url)}
21 response = JSONResponse(data)
22 await response(scope, receive, send)
23
24 client = test_client_factory(app)
25 response = client.get("/123?a=abc")
26 assert response.json() == {"method": "GET", "url": "http://testserver/123?a=abc"}
27
28 response = client.get("https://example.org:123/")
29 assert response.json() == {"method": "GET", "url": "https://example.org:123/"}
30
31
32def test_request_query_params(test_client_factory: TestClientFactory) -> None:

Callers

nothing calls this directly

Calls 3

test_client_factoryFunction · 0.85
jsonMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected