Skip to content

Conftest

client()

Creates a TestClient instance bound to the FastAPI app.

This fixture ensures that a fresh client is available for each test function, allowing for isolated HTTP request testing against the application endpoints.

Returns:

Name Type Description
TestClient

The HTTP client for making requests to the app.

Source code in api/tests/conftest.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
@pytest.fixture
def client():
    """
    Creates a `TestClient` instance bound to the FastAPI app.

    This fixture ensures that a fresh client is available for each test function,
    allowing for isolated HTTP request testing against the application endpoints.

    Returns:
        TestClient: The HTTP client for making requests to the app.
    """
    return TestClient(app)

mock_settings(monkeypatch)

Overrides application settings for the testing environment.

Adjustments:

  • MLFLOW_ENABLE = False: Disables telemetry to prevent test runs from polluting the production MLflow server with noise data.

Parameters:

Name Type Description Default
monkeypatch

Pytest's fixture for safely modifying attributes/env vars.

required

Returns:

Name Type Description
Settings

The modified settings object.

Source code in api/tests/conftest.py
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
@pytest.fixture
def mock_settings(monkeypatch):
    """
    Overrides application settings for the testing environment.

    **Adjustments:**

    * **MLFLOW_ENABLE = False:** Disables telemetry to prevent test runs from
        polluting the production MLflow server with noise data.

    Args:
        monkeypatch: Pytest's fixture for safely modifying attributes/env vars.

    Returns:
        Settings: The modified settings object.
    """
    settings = get_settings()
    monkeypatch.setattr(settings, "MLFLOW_ENABLE", False)
    return settings