Skip to content

ccproxy.testing.endpoints.models

ccproxy.testing.endpoints.models

Data models shared by the endpoint testing helpers.

EndpointTest dataclass

EndpointTest(
    name, endpoint, stream, request, model, description=""
)

Configuration for a single endpoint test.

EndpointRequestResult dataclass

EndpointRequestResult(
    phase, method, status_code, stream, details=dict()
)

Outcome of a single HTTP request made while executing a test.

EndpointTestResult dataclass

EndpointTestResult(
    test,
    index,
    success,
    error=None,
    exception=None,
    request_results=list(),
)

Result of running a single endpoint test.

name property

name

Convenience access to the test name.

EndpointTestRunSummary dataclass

EndpointTestRunSummary(
    base_url,
    results,
    successful_count,
    failure_count,
    errors=list(),
)

Summary of executing a batch of endpoint tests.

total property

total

Total number of executed tests.

failed_results property

failed_results

Return the list of failed test results.

all_passed

all_passed()

Return True when every executed test succeeded.

Source code in ccproxy/testing/endpoints/models.py
def all_passed(self) -> bool:
    """Return True when every executed test succeeded."""
    return self.failure_count == 0 and not self.errors

assert_success

assert_success()

Raise AssertionError if any test failed (useful for pytest).

Source code in ccproxy/testing/endpoints/models.py
def assert_success(self) -> None:
    """Raise AssertionError if any test failed (useful for pytest)."""
    if self.all_passed():
        return

    failed_names = ", ".join(result.name for result in self.failed_results)
    parts = []
    if self.failure_count:
        parts.append(
            f"{self.failure_count} endpoint test(s) failed: {failed_names}"
        )
    if self.errors:
        parts.append("; additional errors: " + "; ".join(self.errors))

    raise AssertionError(" ".join(parts) if parts else "Endpoint test run failed")