"""Tests for exception handling."""

import pytest
from sed_sh.exceptions import (
    SedSHError,
    AuthenticationError,
    RateLimitError,
    ResourceNotFoundError,
    InvalidRequestError,
    PaymentRequiredError,
    ServerError,
)


class TestExceptions:
    """Test suite for custom exceptions."""

    def test_base_exception(self):
        """Test base SedSHError exception."""
        error = SedSHError("Test error", status_code=400)
        assert error.message == "Test error"
        assert error.status_code == 400
        assert "[400]" in str(error)

    def test_base_exception_without_status_code(self):
        """Test base exception without status code."""
        error = SedSHError("Test error")
        assert str(error) == "Test error"
        assert error.status_code is None

    def test_authentication_error(self):
        """Test AuthenticationError."""
        error = AuthenticationError("Invalid API key")
        assert isinstance(error, SedSHError)
        assert "Invalid API key" in str(error)

    def test_rate_limit_error(self):
        """Test RateLimitError."""
        error = RateLimitError("Too many requests")
        assert isinstance(error, SedSHError)
        assert "Too many requests" in str(error)

    def test_resource_not_found_error(self):
        """Test ResourceNotFoundError."""
        error = ResourceNotFoundError("Link not found")
        assert isinstance(error, SedSHError)
        assert "Link not found" in str(error)

    def test_invalid_request_error(self):
        """Test InvalidRequestError."""
        error = InvalidRequestError("Invalid URL format")
        assert isinstance(error, SedSHError)
        assert "Invalid URL format" in str(error)

    def test_payment_required_error(self):
        """Test PaymentRequiredError."""
        error = PaymentRequiredError("Insufficient balance")
        assert isinstance(error, SedSHError)
        assert "Insufficient balance" in str(error)

    def test_server_error(self):
        """Test ServerError."""
        error = ServerError("Internal server error")
        assert isinstance(error, SedSHError)
        assert "Internal server error" in str(error)
