Exit both command-line tools with failure status on operational errors
This commit is contained in:
parent
dc24c4d4fe
commit
bc37483b1a
1 changed files with 20 additions and 0 deletions
|
|
@ -1,5 +1,8 @@
|
|||
import importlib
|
||||
from threading import Event
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
from watchdog.events import FileClosedEvent, FileModifiedEvent, FileMovedEvent
|
||||
|
||||
from great_ai.deploy.reload_event_handler import ReloadEventHandler
|
||||
|
|
@ -25,3 +28,18 @@ def test_reload_debounces_edit_and_replacement_events() -> None:
|
|||
handler.close()
|
||||
handler.dispatch(FileModifiedEvent("service.py"))
|
||||
assert calls == ["restart"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"module_name, operation",
|
||||
[
|
||||
("great_ai.__main__", "serve"),
|
||||
("great_ai.large_file.__main__", "handle_command"),
|
||||
],
|
||||
)
|
||||
def test_cli_operational_errors_exit_nonzero(module_name: str, operation: str) -> None:
|
||||
module = importlib.import_module(module_name)
|
||||
with patch.object(module, operation, side_effect=ValueError("failed")):
|
||||
with pytest.raises(SystemExit) as error:
|
||||
module.main()
|
||||
assert error.value.code == 1
|
||||
|
|
|
|||
Loading…
Reference in a new issue