Skip to content

api_client

Scope: function | Returns: FlaskClient

The api_client fixture provides an unauthenticated HTTP test client. Use it when testing endpoints that do not require authentication, or when testing authentication behavior itself.

Warning

Only one web client fixture (web_client, web_client_non_admin, web_client_other_non_admin, api_client) can be used in a single test.

Basic usage

def test_unauthenticated_request_is_rejected(api_client, prefix_url):
    response = api_client.get(prefix_url("api/v1/limeobject/company/"))

    assert response.status_code == 401