Agentic-RagBot / tests /test_exceptions.py
T0X1N's picture
chore: codebase audit and fixes (ruff, mypy, pytest)
9659593
"""
Tests for src/exceptions.py — domain exception hierarchy.
"""
from src.exceptions import (
AnalysisError,
BiomarkerError,
CacheError,
DatabaseError,
EmbeddingError,
GuardrailError,
LLMError,
MediGuardError,
ObservabilityError,
OllamaConnectionError,
OutOfScopeError,
PDFParsingError,
SearchError,
TelegramError,
)
def test_all_exceptions_inherit_from_root():
"""Every domain exception should inherit from MediGuardError."""
for exc_cls in [
DatabaseError,
SearchError,
EmbeddingError,
PDFParsingError,
LLMError,
OllamaConnectionError,
BiomarkerError,
AnalysisError,
GuardrailError,
OutOfScopeError,
CacheError,
ObservabilityError,
TelegramError,
]:
assert issubclass(exc_cls, MediGuardError), f"{exc_cls.__name__} must inherit MediGuardError"
def test_ollama_inherits_llm():
assert issubclass(OllamaConnectionError, LLMError)
def test_exception_message():
exc = SearchError("OpenSearch timeout")
assert str(exc) == "OpenSearch timeout"
assert isinstance(exc, MediGuardError)