def test_view_from_obj(app: App, client): class MyView: async def get(self, req, res): pass app.route("/")(MyView()) assert client.get("/").status_code == 200
def test_mount(app: App, client, path): other = App() requested_path = None async def view(req, res): nonlocal requested_path requested_path = req.url.path other.route("/")(view) other.route("/foo")(view) app.mount("/other", other) r = client.get(path) assert r.status_code == 200 assert requested_path is not None assert requested_path.rstrip("/") == path
def test_with_route_parameter(app: App, client, view): app.route("/hi/{who}")(view) r = client.get("/hi/peeps") assert r.status_code == 200 assert r.text == "Hello, peeps!"
def test_basic(app: App, client, view): app.route("/hi")(view) r = client.get("/hi") assert r.status_code == 200 assert r.text == "Hello, providers!"