"""Tests for custom exceptions."""
import pytest
from silico.exceptions import (
    SilicoError,
    AuthenticationError,
    RateLimitError,
    InsufficientBalanceError,
    InvalidSymbolError,
    NetworkError,
)


def test_silico_error_base():
    """Base exception should be catchable."""
    with pytest.raises(SilicoError):
        raise SilicoError("test error")


def test_authentication_error():
    """Auth errors should include API key hint."""
    error = AuthenticationError("Invalid API key")
    assert "Invalid API key" in str(error)
    assert isinstance(error, SilicoError)


def test_rate_limit_error_with_retry():
    """Rate limit errors should include retry info."""
    error = RateLimitError("Too many requests", retry_after=30)
    assert error.retry_after == 30
    assert "30" in str(error)


def test_insufficient_balance_error():
    """Balance errors should show current and required."""
    error = InsufficientBalanceError(
        message="Not enough USDC",
        current_balance=50.0,
        required_balance=100.0
    )
    assert error.current_balance == 50.0
    assert error.required_balance == 100.0
    assert "50.0" in str(error)
    assert "100.0" in str(error)


def test_invalid_symbol_error():
    """Symbol errors should suggest valid symbols."""
    error = InvalidSymbolError(
        symbol="INVALID/USD",
        valid_symbols=["SOL/USDC", "BONK/USDC"]
    )
    assert error.symbol == "INVALID/USD"
    assert "SOL/USDC" in str(error)


def test_network_error():
    """Network errors should be retryable."""
    error = NetworkError("Connection timeout")
    assert isinstance(error, SilicoError)
