"""Tests for custom exceptions.""" import pytest from capa_de_integracion.exceptions import FirestorePersistenceError def test_firestore_persistence_error_basic(): """Test FirestorePersistenceError with message only.""" error = FirestorePersistenceError("Test error message") assert str(error) == "Test error message" assert error.cause is None def test_firestore_persistence_error_with_cause(): """Test FirestorePersistenceError with cause exception.""" cause = ValueError("Original error") error = FirestorePersistenceError("Wrapped error", cause=cause) assert str(error) == "Wrapped error" assert error.cause is cause assert isinstance(error.cause, ValueError) assert str(error.cause) == "Original error" def test_firestore_persistence_error_inheritance(): """Test that FirestorePersistenceError is an Exception.""" error = FirestorePersistenceError("Test") assert isinstance(error, Exception) def test_firestore_persistence_error_can_be_raised(): """Test that the exception can be raised and caught.""" with pytest.raises(FirestorePersistenceError) as exc_info: raise FirestorePersistenceError("Test error") assert str(exc_info.value) == "Test error"