Spaces:
Sleeping
Sleeping
File size: 1,184 Bytes
1e732dd 9659593 1e732dd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | """
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)
|