test(ocr): verify load failure does not cache broken entry in SenderModelRegistry

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-04-17 20:19:40 +02:00
committed by marcel
parent c3939e0f13
commit 16787f2771

View File

@@ -63,3 +63,13 @@ def test_path_outside_models_dir_raises():
registry = _make_registry()
with pytest.raises(ValueError, match="not allowed"):
registry.get_model("/etc/passwd")
def test_load_failure_does_not_cache_broken_entry():
"""A failed load must not leave a broken entry in the cache."""
registry = _make_registry()
with patch("engines.kraken._load_sender_model", side_effect=RuntimeError("corrupt model")):
with pytest.raises(RuntimeError, match="corrupt model"):
registry.get_model("/app/models/sender_bad.mlmodel")
assert registry.size() == 0