Test with FastApi TestClient return 422 Unprocessable Entity

272 views Asked by At

I'm trying to run the following test with TestClient FastAPI on following endpoint.

I'm getting 422 Unprocessable Entity

def test_nodes():
    """
    this test assumes a specific id scheme, which is subject to change
    """
    response = client.get("/graphs/0/nodes?id=n:0,n:1,n:2,n:3")
    assert response.status_code == 200
@app.get("/graphs/{tree_id}/nodes")
async def get_nodes(tree_id: str, ids: str):
    server_tree = get_server_tree(tree_id)

    ids = ids.split(",")
    logging.info(ids)
    return server_tree.get_nodes(ids, short=False)

I'm also getting this message:

Failed: [undefined]AssertionError: assert {'detail': [{'loc': ['query', 'ids'], 'msg': 'field required', 'type': 'value_error.missing'}]} == 200

What could that mean? Any help on towards where to look would be really appreciated.

Thank you for your support and time

0

There are 0 answers