Skip to content

ccproxy.testing.endpoints.config

ccproxy.testing.endpoints.config

Configuration and static data for endpoint test execution.

APIFormatTools

Bases: Protocol

Protocol for API format-specific tool result handling.

build_continuation_request

build_continuation_request(
    initial_request, original_response, tool_results
)

Build a continuation request with tool results for this API format.

Source code in ccproxy/testing/endpoints/config.py
def build_continuation_request(
    self,
    initial_request: dict[str, Any],
    original_response: dict[str, Any],
    tool_results: list[dict[str, Any]],
) -> dict[str, Any]:
    """Build a continuation request with tool results for this API format."""

OpenAIFormatTools

Handle tool result continuation for the OpenAI API format.

AnthropicFormatTools

Handle tool result continuation for the Anthropic API format.

ResponsesFormatTools

Handle tool result continuation for the Responses API format.

ProviderConfig dataclass

ProviderConfig(
    name,
    base_path,
    model,
    supported_formats,
    description_prefix,
)

Configuration for a provider's endpoints and capabilities.

FormatConfig dataclass

FormatConfig(
    name, endpoint_path, request_type_base, description
)

Configuration mapping API format to request types and endpoint paths.

generate_endpoint_tests

generate_endpoint_tests()

Generate all endpoint test permutations from provider and format configurations.

Source code in ccproxy/testing/endpoints/config.py
def generate_endpoint_tests() -> list[EndpointTest]:
    """Generate all endpoint test permutations from provider and format configurations."""

    tests: list[EndpointTest] = []

    for provider_key, provider in PROVIDER_CONFIGS.items():
        for format_name in provider.supported_formats:
            format_config = FORMAT_CONFIGS.get(format_name)
            if not format_config:
                continue

            endpoint = provider.base_path + format_config.endpoint_path

            for is_streaming in [True, False]:
                stream_suffix = "_stream" if is_streaming else "_non_stream"
                request_type = format_config.request_type_base + stream_suffix

                if request_type not in REQUEST_DATA:
                    continue

                stream_name_part = "_stream" if is_streaming else ""
                test_name = f"{provider_key}_{format_config.name}{stream_name_part}"

                stream_desc = "streaming" if is_streaming else "non-streaming"
                description = f"{provider.description_prefix} {format_config.description} {stream_desc}"

                tests.append(
                    EndpointTest(
                        name=test_name,
                        endpoint=endpoint,
                        stream=is_streaming,
                        request=request_type,
                        model=provider.model,
                        description=description,
                    )
                )

    return tests

add_provider

add_provider(
    name,
    base_path,
    model,
    supported_formats,
    description_prefix,
)

Add a new provider configuration and regenerate endpoint tests.

Source code in ccproxy/testing/endpoints/config.py
def add_provider(
    name: str,
    base_path: str,
    model: str,
    supported_formats: list[str],
    description_prefix: str,
) -> None:
    """Add a new provider configuration and regenerate endpoint tests."""

    global ENDPOINT_TESTS

    PROVIDER_CONFIGS[name] = ProviderConfig(
        name=name,
        base_path=base_path,
        model=model,
        supported_formats=supported_formats,
        description_prefix=description_prefix,
    )

    ENDPOINT_TESTS = generate_endpoint_tests()

add_format

add_format(
    name, endpoint_path, request_type_base, description
)

Add a new format configuration and regenerate endpoint tests.

Source code in ccproxy/testing/endpoints/config.py
def add_format(
    name: str,
    endpoint_path: str,
    request_type_base: str,
    description: str,
) -> None:
    """Add a new format configuration and regenerate endpoint tests."""

    global ENDPOINT_TESTS

    FORMAT_CONFIGS[name] = FormatConfig(
        name=name,
        endpoint_path=endpoint_path,
        request_type_base=request_type_base,
        description=description,
    )

    ENDPOINT_TESTS = generate_endpoint_tests()

list_available_tests

list_available_tests()

Generate a formatted list of available tests for help text.

Source code in ccproxy/testing/endpoints/config.py
def list_available_tests() -> str:
    """Generate a formatted list of available tests for help text."""

    lines = ["Available tests:"]
    for i, test in enumerate(ENDPOINT_TESTS, 1):
        lines.append(f"  {i:2d}. {test.name:<30} - {test.description}")
    return "\n".join(lines)