swadhinbiswas p3n-q: add Plugins, Testing Client, UploadFile, Database API reference pages · 7/24/2026
e3fa5cb
55 lines · 1.2 KB
Raw Download

title: Testing Client API
description: Reference for the in-process HTTP test client.

JustAPITestClient

The test client sends HTTP requests to your application without starting a real server, using tokio duplex streams.

from justapi import JustAPITestClient

client = JustAPITestClient(app)

Methods

response = client.get("/items/42")
response = client.post("/items/", body={"name": "Item"})
response = client.put("/items/42", body={"name": "Updated"})
response = client.patch("/items/42", body={"name": "Patched"})
response = client.delete("/items/42")

Response Object

Attribute Type Description
status int HTTP status code
body bytes Raw response body
json() dict Parsed JSON body

Example Test

from justapi import JustAPIApp, JustAPITestClient

app = JustAPIApp()

@app.get("/ping")
def ping(request):
    return {"status": "ok"}

client = JustAPITestClient(app)
response = client.get("/ping")
assert response.status == 200
assert response.json() == {"status": "ok"}

See Also