ccproxy.testing¶
ccproxy.testing
¶
Testing utilities and mock response generation for CCProxy.
This package provides comprehensive testing utilities including: - Mock response generation for bypass mode - Request payload builders for dual-format testing - Response processing and metrics collection - Traffic pattern generation and scenario management
MessageContentGenerator
¶
Generate realistic message content for testing.
Source code in ccproxy/testing/content_generation.py
get_request_message_content
¶
Get request message content based on type.
Source code in ccproxy/testing/content_generation.py
get_response_content
¶
Generate response content with realistic token counts.
Source code in ccproxy/testing/content_generation.py
PayloadBuilder
¶
Build request payloads for different API formats.
Source code in ccproxy/testing/content_generation.py
build_anthropic_payload
¶
Build Anthropic format payload.
Source code in ccproxy/testing/content_generation.py
build_openai_payload
¶
Build OpenAI format payload.
Source code in ccproxy/testing/content_generation.py
build_payload
¶
Build request payload based on scenario format.
Source code in ccproxy/testing/content_generation.py
RealisticMockResponseGenerator
¶
Generate realistic mock responses with proper randomization.
Source code in ccproxy/testing/mock_responses.py
generate_response_content
¶
Generate response content with realistic token counts.
generate_cache_tokens
¶
Generate realistic cache token counts.
Source code in ccproxy/testing/mock_responses.py
should_simulate_error
¶
generate_error_response
¶
Generate realistic error response.
Source code in ccproxy/testing/mock_responses.py
generate_realistic_anthropic_stream
¶
generate_realistic_anthropic_stream(
request_id,
model,
content,
input_tokens,
output_tokens,
cache_read_tokens,
cache_write_tokens,
)
Generate realistic Anthropic streaming chunks.
Source code in ccproxy/testing/mock_responses.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
|
generate_realistic_openai_stream
¶
Generate realistic OpenAI streaming chunks by converting Anthropic format.
Source code in ccproxy/testing/mock_responses.py
calculate_realistic_cost
¶
calculate_realistic_cost(
input_tokens,
output_tokens,
model,
cache_read_tokens,
cache_write_tokens,
)
Calculate realistic cost based on current Claude pricing.
Source code in ccproxy/testing/mock_responses.py
MetricsExtractor
¶
Extract metrics from API responses.
extract_token_metrics
staticmethod
¶
Extract token usage from response data.
Source code in ccproxy/testing/response_handlers.py
extract_content
staticmethod
¶
Extract text content from response data.
Source code in ccproxy/testing/response_handlers.py
ResponseHandler
¶
Handle responses from both Anthropic and OpenAI formats.
process_response
¶
Process response based on format and streaming.
Source code in ccproxy/testing/response_handlers.py
ScenarioGenerator
¶
Generate request scenarios based on traffic configuration.
Source code in ccproxy/testing/scenarios.py
generate_scenarios
¶
Generate request scenarios based on configuration.
Source code in ccproxy/testing/scenarios.py
TrafficPatternAnalyzer
¶
Analyze and validate traffic patterns.
analyze_distribution
staticmethod
¶
Analyze the distribution of scenarios.