Skip to content

App Tests #62

Open
Open
@ZeroIntensity

Description

@ZeroIntensity

The user should be able to write tests for their view app, like so:

@app.get("/")
async def index():
    ...

@index.test("my test name")  # could also be left blank, like @index.test
async def test_index(route: view.Test):
    assert (await route(query={"hello": "world"})).response == "foo"

# OR, it could be synchronous

@index.test("my test name")
def test_index(route: view.SyncTest):
    assert route(...).response == "..."  # manually call event loop internally

Then, the end user should be able to run their tests, like so:

$ view test
GET /hello (my test name) passed in 0.43ms
GET /fail failed after 1s:

assert route(...).response == "..."
AssertionError

They could also run tests for specific routes:

$ view test /hello --methods GET,POST
GET /hello (my test name) passed in 0.43ms

This should integrate with a virtual I/O system in #10 (i.e. database connections won't actually be called, and instead just made in memory for testing purposes)

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiThis has to do with the Python API (view)cliThis has to do with the CLI ($ view)featureNew feature

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions