Spaces:
Sleeping
Sleeping
Download tests/test_error_utils.py from SameerSingh2/Gargi_AI: direct link, hf CLI and curl.
- Browser
- Download file 958 Bytes
-
https://huggingface.co/spaces/SameerSingh2/Gargi_AI/resolve/main/tests/test_error_utils.py
- Command line
-
hf download hf://spaces/SameerSingh2/Gargi_AI/tests/test_error_utils.py
-
curl -L -o test_error_utils.py https://huggingface.co/spaces/SameerSingh2/Gargi_AI/resolve/main/tests/test_error_utils.py
958 Bytes
| from google.genai.errors import ClientError | |
| from gargi_ai.error_utils import summarize_provider_error | |
| def test_provider_error_summary_detects_quota_retry_delay(): | |
| exc = ClientError( | |
| 429, | |
| { | |
| "error": { | |
| "code": 429, | |
| "message": "quota exceeded", | |
| "status": "RESOURCE_EXHAUSTED", | |
| "details": [ | |
| {"retryDelay": "42s"}, | |
| { | |
| "violations": [ | |
| { | |
| "quotaMetric": "generate_content_free_tier_requests", | |
| } | |
| ] | |
| }, | |
| ], | |
| } | |
| }, | |
| ) | |
| info = summarize_provider_error(exc) | |
| assert info.code == "RATE_LIMITED" | |
| assert info.expected is True | |
| assert info.retry_delay == "42s" | |
| assert info.quota_metric == "generate_content_free_tier_requests" | |