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

Function test_request_url

tests/test_requests.py:17–29  ·  tests/test_requests.py::test_request_url
(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 = {class="st">"method": request.method, class="st">"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(class="st">"/123?a=abc")
26 assert response.json() == {class="st">"method": class="st">"GET", class="st">"url": class="st">"http://testserver/123?a=abc"}
27
28 response = client.get(class="st">"https://example.org:123/")
29 assert response.json() == {class="st">"method": class="st">"GET", class="st">"url": class="st">"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