generated from john/python-template
Error handling added to MVP according to error_handling.md guideline
This commit is contained in:
@@ -60,9 +60,12 @@ class TestPromptLoading:
|
||||
prompt_dir.mkdir()
|
||||
|
||||
settings = Settings(openrouter_api_key="test-key", prompt_dir=prompt_dir)
|
||||
with pytest.raises(PromptLoadError):
|
||||
with pytest.raises(PromptLoadError) as exc_info:
|
||||
load_prompt_text(settings=settings)
|
||||
|
||||
assert exc_info.value.category.value == "infrastructure_persistent_error"
|
||||
assert "verify prompt_dir" in exc_info.value.suggestion.lower()
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
class TestImageLoading:
|
||||
@@ -83,9 +86,12 @@ class TestImageLoading:
|
||||
"""Image loader raises TranscriptionError when image file does not exist."""
|
||||
missing = tmp_path / "missing.png"
|
||||
|
||||
with pytest.raises(TranscriptionError):
|
||||
with pytest.raises(TranscriptionError) as exc_info:
|
||||
load_image_payload(missing)
|
||||
|
||||
assert exc_info.value.category.value == "not_found_error"
|
||||
assert "verify" in exc_info.value.suggestion.lower()
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
class TestTranscriptionService:
|
||||
@@ -123,5 +129,9 @@ class TestTranscriptionService:
|
||||
settings = Settings(openrouter_api_key="test-key", prompt_dir=prompt_dir)
|
||||
provider = _FakeProvider(error=ProviderError("upstream failure"))
|
||||
|
||||
with pytest.raises(TranscriptionError):
|
||||
with pytest.raises(TranscriptionError) as exc_info:
|
||||
transcribe_document_image(image_path, settings=settings, provider=provider)
|
||||
|
||||
assert exc_info.value.category.value == "external_provider_error"
|
||||
assert exc_info.value.retriable is True
|
||||
assert "retry" in exc_info.value.suggestion.lower()
|
||||
|
||||
Reference in New Issue
Block a user