"""
Unit tests for custom exceptions.
"""

import pytest
from app.core.exceptions import (
    AppException,
    NotFoundError,
    UnauthorizedError,
    ForbiddenError,
    BadRequestError,
    RateLimitError,
    KalshiAPIError,
)


class TestExceptions:
    def test_not_found_error(self):
        err = NotFoundError("Instance not found")
        assert err.status_code == 404
        assert err.message == "Instance not found"

    def test_unauthorized_error(self):
        err = UnauthorizedError()
        assert err.status_code == 401
        assert err.message == "Unauthorized"

    def test_forbidden_error(self):
        err = ForbiddenError("No access")
        assert err.status_code == 403

    def test_bad_request_error(self):
        err = BadRequestError("Invalid input")
        assert err.status_code == 400

    def test_rate_limit_error(self):
        err = RateLimitError()
        assert err.status_code == 429

    def test_kalshi_api_error(self):
        err = KalshiAPIError("Connection timeout")
        assert err.status_code == 502
        assert err.message == "Connection timeout"

    def test_base_exception(self):
        err = AppException("Generic error", 500)
        assert err.status_code == 500
        assert str(err) == "Generic error"
