"""
Tests for wallet_utils exceptions.
"""
from django.test import TestCase

from wallet_utils.exceptions import (
    WalletOperationError,
    InsufficientBalanceError,
    InvalidPointTypeError,
    InvalidParamsError,
)


class WalletOperationErrorTests(TestCase):
    """Tests for WalletOperationError base exception."""
    
    def test_wallet_operation_error(self):
        """Test WalletOperationError can be raised."""
        with self.assertRaises(WalletOperationError) as cm:
            raise WalletOperationError("Test error")
        
        self.assertEqual(str(cm.exception), "Test error")
    
    def test_wallet_operation_error_inheritance(self):
        """Test WalletOperationError is an Exception."""
        self.assertTrue(issubclass(WalletOperationError, Exception))


class InsufficientBalanceErrorTests(TestCase):
    """Tests for InsufficientBalanceError."""
    
    def test_insufficient_balance_error(self):
        """Test InsufficientBalanceError with available and requested."""
        error = InsufficientBalanceError(
            "Insufficient balance",
            available=100.0,
            requested=200.0,
        )
        
        self.assertEqual(str(error), "Insufficient balance")
        self.assertEqual(error.available, 100.0)
        self.assertEqual(error.requested, 200.0)
    
    def test_insufficient_balance_error_inheritance(self):
        """Test InsufficientBalanceError inherits from WalletOperationError."""
        self.assertTrue(issubclass(InsufficientBalanceError, WalletOperationError))
    
    def test_insufficient_balance_error_none_values(self):
        """Test InsufficientBalanceError with None values."""
        error = InsufficientBalanceError("Error")
        
        self.assertIsNone(error.available)
        self.assertIsNone(error.requested)


class InvalidPointTypeErrorTests(TestCase):
    """Tests for InvalidPointTypeError."""
    
    def test_invalid_point_type_error(self):
        """Test InvalidPointTypeError with point_type."""
        error = InvalidPointTypeError(
            "Invalid point type",
            point_type="invalid_type",
        )
        
        self.assertEqual(str(error), "Invalid point type")
        self.assertEqual(error.point_type, "invalid_type")
    
    def test_invalid_point_type_error_inheritance(self):
        """Test InvalidPointTypeError inherits from WalletOperationError."""
        self.assertTrue(issubclass(InvalidPointTypeError, WalletOperationError))
    
    def test_invalid_point_type_error_none_value(self):
        """Test InvalidPointTypeError with None point_type."""
        error = InvalidPointTypeError("Error")
        
        self.assertIsNone(error.point_type)


class InvalidParamsErrorTests(TestCase):
    """Tests for InvalidParamsError."""
    
    def test_invalid_params_error(self):
        """Test InvalidParamsError with method."""
        error = InvalidParamsError(
            "Invalid params",
            method="add_point",
        )
        
        self.assertEqual(str(error), "Invalid params")
        self.assertEqual(error.method, "add_point")
    
    def test_invalid_params_error_inheritance(self):
        """Test InvalidParamsError inherits from WalletOperationError."""
        self.assertTrue(issubclass(InvalidParamsError, WalletOperationError))
    
    def test_invalid_params_error_none_value(self):
        """Test InvalidParamsError with None method."""
        error = InvalidParamsError("Error")
        
        self.assertIsNone(error.method)
