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:
@@ -63,3 +63,13 @@ def test_path_outside_models_dir_raises():
|
|||||||
registry = _make_registry()
|
registry = _make_registry()
|
||||||
with pytest.raises(ValueError, match="not allowed"):
|
with pytest.raises(ValueError, match="not allowed"):
|
||||||
registry.get_model("/etc/passwd")
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user