Watch
1
0
Fork
You've already forked Seyyed_arc
0
forked from hesabix/arc
Seyyed_arc/hesabixAPI/tests/test_ai_retry_policy.py
2026-05-28 14:18:39 +00:00

23 lines
697 B
Python

"""تست سیاست retry LLM."""
from app.core.responses import ApiError
from app.services.ai.ai_retry_policy import is_retryable_error
def test_retryable_api_error_codes():
assert is_retryable_error(
ApiError("RATE_LIMIT_EXCEEDED", "limit", http_status=429)
)
assert is_retryable_error(
ApiError("AI_PROVIDER_ERROR", "server", http_status=500)
)
def test_non_retryable_api_error():
assert not is_retryable_error(
ApiError("INVALID_API_KEY", "bad key", http_status=400)
)
def test_retryable_message_tokens():
assert is_retryable_error(TimeoutError("connection timed out"))
assert is_retryable_error(Exception("rate_limit exceeded"))