"""Tests for ai4gh.core.exceptions."""

from __future__ import annotations

from ai4gh.core.exceptions import (
    AI4GHError,
    AuthError,
    ConfigError,
    NotFoundError,
    PluginError,
    RateLimitError,
    ServerError,
    TransportError,
    ValidationError,
)


class TestExceptionHierarchy:
    def test_base_error(self) -> None:
        err = AI4GHError("test error")
        assert str(err) == "test error"
        assert err.status_code is None

    def test_base_error_with_status(self) -> None:
        err = AI4GHError("test", status_code=500)
        assert err.status_code == 500

    def test_config_error_inherits(self) -> None:
        err = ConfigError("bad config")
        assert isinstance(err, AI4GHError)

    def test_auth_error_inherits(self) -> None:
        err = AuthError("bad auth")
        assert isinstance(err, AI4GHError)

    def test_transport_error_inherits(self) -> None:
        err = TransportError("network error")
        assert isinstance(err, AI4GHError)

    def test_not_found_defaults(self) -> None:
        err = NotFoundError()
        assert err.status_code == 404
        assert isinstance(err, TransportError)

    def test_rate_limit_defaults(self) -> None:
        err = RateLimitError()
        assert err.status_code == 429
        assert err.retry_after is None

    def test_rate_limit_with_retry(self) -> None:
        err = RateLimitError(retry_after=30.0)
        assert err.retry_after == 30.0

    def test_server_error_inherits(self) -> None:
        err = ServerError("internal error", status_code=500)
        assert isinstance(err, TransportError)

    def test_plugin_error_inherits(self) -> None:
        err = PluginError("no plugin")
        assert isinstance(err, AI4GHError)

    def test_validation_error_inherits(self) -> None:
        err = ValidationError("invalid data")
        assert isinstance(err, AI4GHError)
