generated from john/python-template
@@ -3,6 +3,7 @@ import pytest
|
||||
from transcription.errors import AppError
|
||||
from transcription.errors import ErrorCategory
|
||||
from transcription.ui.components.error_presenter import display_error_category
|
||||
from transcription.ui.components.error_presenter import display_failure_detail
|
||||
from transcription.ui.components.error_presenter import run_ui_action
|
||||
|
||||
|
||||
@@ -17,6 +18,44 @@ def test_display_error_category_uses_canonical_taxonomy():
|
||||
assert display_error_category(AppError("x", category=ErrorCategory.INFRA_PERSISTENT)) == "internal"
|
||||
|
||||
|
||||
def test_display_failure_detail_returns_none_for_missing_detail():
|
||||
assert display_failure_detail(None) is None
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("raw_detail", "expected_basename"),
|
||||
[
|
||||
(
|
||||
(
|
||||
"[internal_unexpected_error] Unexpected error during worker.process_job. | "
|
||||
"detail=PermissionError: [Errno 13] Permission denied: '/app/uploads/documents/abc/page-1.jpg' | "
|
||||
"suggestion=Retry once. | error_id=deadbeef"
|
||||
),
|
||||
"page-1.jpg",
|
||||
),
|
||||
(
|
||||
(
|
||||
"[infrastructure_persistent_error] Prompt file not found: transcribe_document.md | "
|
||||
"detail=FileNotFoundError: [Errno 2] No such file or directory: "
|
||||
r"'C:\app\prompts\transcribe_document.md' | "
|
||||
"suggestion=Verify PROMPT_DIR. | error_id=feedface"
|
||||
),
|
||||
"transcribe_document.md",
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_display_failure_detail_strips_absolute_paths_from_detail_segment(raw_detail, expected_basename):
|
||||
rendered = display_failure_detail(raw_detail)
|
||||
|
||||
assert rendered is not None
|
||||
assert rendered.startswith("[")
|
||||
assert "suggestion=" in rendered
|
||||
assert "error_id=" in rendered
|
||||
assert expected_basename in rendered
|
||||
assert "/app/uploads/documents/abc/page-1.jpg" not in rendered
|
||||
assert r"C:\app\prompts\transcribe_document.md" not in rendered
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_run_ui_action_returns_success_value():
|
||||
outcome = await run_ui_action(
|
||||
|
||||
Reference in New Issue
Block a user