"""Test utils"""


def reset_global_config() -> None:
    """Reset the global configuration cache."""
    from databuilder_logic_sdk.core import config as config_module

    config_module._config_instance = None


def gen_test_config(
    embedding: dict | None = None,
    rerank: dict | None = None,
    ontology: dict | None = None,
    workspace_id: str | None = None,
) -> dict:
    """Generate a test configuration dictionary."""
    if embedding is None:
        embedding = {
            "endpoint": "http://embedding.service",
            "modelServingName": "embedding_model_v1",
            "baseModelName": "base_embedding_model",
        }
    if rerank is None:
        rerank = {
            "endpoint": "http://rerank.service",
            "modelServingName": "rerank_model_v1",
            "baseModelName": "base_rerank_model",
        }
    if ontology is None:
        ontology = {
            "endpoint": "http://ontology.service",
            "token": "ontology_service_token",
        }
    if workspace_id is None:
        workspace_id = "workspace_123"

    return {
        "embedding": embedding,
        "rerank": rerank,
        "ontology": ontology,
        "workspaceId": workspace_id,
    }
