Spaces:
Running
Running
Download tests/core/test_failure_protocol_mapping.py from dherain24/claude-proxy: direct link, hf CLI and curl.
- Browser
- Download file 2.98 kB
-
https://huggingface.co/spaces/dherain24/claude-proxy/resolve/main/tests/core/test_failure_protocol_mapping.py
- Command line
-
hf download hf://spaces/dherain24/claude-proxy/tests/core/test_failure_protocol_mapping.py
-
curl -L -o test_failure_protocol_mapping.py https://huggingface.co/spaces/dherain24/claude-proxy/resolve/main/tests/core/test_failure_protocol_mapping.py
2.98 kB
| """Canonical execution failures and their protocol-owned wire mappings.""" | |
| import pytest | |
| from free_claude_code.core.anthropic.errors import ( | |
| anthropic_error_type_for_failure, | |
| anthropic_failure_payload, | |
| ) | |
| from free_claude_code.core.failures import ExecutionFailure, FailureKind | |
| from free_claude_code.core.openai_responses.errors import ( | |
| openai_error_type_for_failure, | |
| openai_failure_payload, | |
| ) | |
| def test_each_protocol_owns_failure_kind_to_wire_type_mapping( | |
| kind: FailureKind, | |
| anthropic_type: str, | |
| openai_type: str, | |
| ) -> None: | |
| assert anthropic_error_type_for_failure(kind) == anthropic_type | |
| assert openai_error_type_for_failure(kind) == openai_type | |
| def test_finalized_status_502_timeout_keeps_existing_api_error_wire_type() -> None: | |
| failure = ExecutionFailure( | |
| kind=FailureKind.TIMEOUT, | |
| status_code=502, | |
| message="Provider request timed out.", | |
| retryable=True, | |
| ) | |
| assert anthropic_failure_payload(failure)["error"]["type"] == "api_error" | |
| assert openai_failure_payload(failure)["error"]["type"] == "api_error" | |
| def test_each_protocol_adds_its_client_compaction_trigger() -> None: | |
| failure = ExecutionFailure( | |
| kind=FailureKind.CONTEXT_WINDOW_EXCEEDED, | |
| status_code=400, | |
| message="Provider input exceeds its context window.\n\nRequest ID: req_context", | |
| retryable=False, | |
| ) | |
| anthropic_error = anthropic_failure_payload(failure)["error"] | |
| openai_error = openai_failure_payload(failure)["error"] | |
| assert anthropic_error == { | |
| "type": "invalid_request_error", | |
| "message": ( | |
| "prompt is too long\n\nProvider input exceeds its context window." | |
| "\n\nRequest ID: req_context" | |
| ), | |
| } | |
| assert openai_error == { | |
| "message": ( | |
| "Provider input exceeds its context window.\n\nRequest ID: req_context" | |
| ), | |
| "type": "invalid_request_error", | |
| "param": None, | |
| "code": "context_length_exceeded", | |
| } | |