Exemplo n.º 1
0
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
Exemplo n.º 2
0
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
Exemplo n.º 3
0
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!"
Exemplo n.º 4
0
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!"