CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
101 lines
2.9 KiB
Python
101 lines
2.9 KiB
Python
"""Tests for perfxpert.providers._exceptions — error taxonomy + DryRunResponse."""
|
|
|
|
import pytest
|
|
|
|
from perfxpert.providers._exceptions import (
|
|
AuthError,
|
|
DryRunResponse,
|
|
FatalError,
|
|
ProviderChainExhausted,
|
|
ProviderError,
|
|
QuotaExceededError,
|
|
RateLimitError,
|
|
TimeoutError as ProviderTimeoutError,
|
|
TransientError,
|
|
)
|
|
|
|
|
|
def test_provider_error_is_exception():
|
|
assert issubclass(ProviderError, Exception)
|
|
|
|
|
|
def test_auth_error_inherits_provider_error():
|
|
assert issubclass(AuthError, ProviderError)
|
|
e = AuthError("anthropic")
|
|
assert "anthropic" in str(e)
|
|
|
|
|
|
def test_rate_limit_error_carries_retry_after():
|
|
e = RateLimitError("openai", retry_after=30.0)
|
|
assert e.provider == "openai"
|
|
assert e.retry_after == 30.0
|
|
|
|
|
|
def test_rate_limit_error_default_retry_after_zero():
|
|
e = RateLimitError("openai")
|
|
assert e.retry_after == 0.0
|
|
|
|
|
|
def test_quota_exceeded_error_tracks_provider_and_model():
|
|
e = QuotaExceededError("openai", model="gpt-4o", message="quota reached")
|
|
assert e.provider == "openai"
|
|
assert e.model == "gpt-4o"
|
|
assert e.raw_message == "quota reached"
|
|
|
|
|
|
def test_transient_error_tracks_kind():
|
|
e = TransientError("anthropic", kind="api_unavailable", message="try again")
|
|
assert e.provider == "anthropic"
|
|
assert e.kind == "api_unavailable"
|
|
assert e.raw_message == "try again"
|
|
|
|
|
|
def test_fatal_error_tracks_raw_message():
|
|
e = FatalError("private", "schema mismatch")
|
|
assert e.provider == "private"
|
|
assert e.raw_message == "schema mismatch"
|
|
|
|
|
|
def test_timeout_error_carries_timeout_seconds():
|
|
e = ProviderTimeoutError("ollama", timeout_seconds=60.0)
|
|
assert e.provider == "ollama"
|
|
assert e.timeout_seconds == 60.0
|
|
|
|
|
|
def test_provider_chain_exhausted_tracks_attempted_providers_and_last_error():
|
|
last_error = RateLimitError("openai", retry_after=30.0)
|
|
e = ProviderChainExhausted(["anthropic", "openai"], last_error=last_error)
|
|
assert e.providers == ("anthropic", "openai")
|
|
assert e.last_error is last_error
|
|
|
|
|
|
def test_dry_run_response_is_singleton():
|
|
from perfxpert.providers._exceptions import DryRunResponse as A
|
|
from perfxpert.providers._exceptions import DryRunResponse as B
|
|
assert A is B
|
|
|
|
|
|
def test_dry_run_response_fields():
|
|
assert DryRunResponse.content == ""
|
|
assert DryRunResponse.provider == "dry_run"
|
|
assert DryRunResponse.model == "dry_run"
|
|
assert DryRunResponse.input_tokens == 0
|
|
assert DryRunResponse.output_tokens == 0
|
|
assert DryRunResponse.total_tokens == 0
|
|
|
|
|
|
def test_public_exports_available_from_package():
|
|
from perfxpert.providers import (
|
|
AuthError,
|
|
DryRunResponse,
|
|
FatalError,
|
|
ProviderChainExhausted,
|
|
ProviderError,
|
|
QuotaExceededError,
|
|
RateLimitError,
|
|
TransientError,
|
|
TimeoutError,
|
|
)
|
|
assert ProviderError is not None
|
|
assert DryRunResponse is not None
|