Improve coverage

This commit is contained in:
2026-02-20 06:02:57 +00:00
parent f848bbf0f2
commit fd6b698077
28 changed files with 2719 additions and 387 deletions

37
tests/test_exceptions.py Normal file
View File

@@ -0,0 +1,37 @@
"""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"