|
@@ -1,3 +1,4 @@
|
|
|
|
|
+import pytest
|
|
|
from src.commands import COMMANDS
|
|
from src.commands import COMMANDS
|
|
|
|
|
|
|
|
|
|
|
|
@@ -19,3 +20,25 @@ def test_unknown_command_not_in_registry():
|
|
|
def test_all_commands_are_callable():
|
|
def test_all_commands_are_callable():
|
|
|
for name, handler in COMMANDS.items():
|
|
for name, handler in COMMANDS.items():
|
|
|
assert callable(handler), f"Command '{name}' is not callable"
|
|
assert callable(handler), f"Command '{name}' is not callable"
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+def test_exit_raises_system_exit(capsys):
|
|
|
|
|
+ with pytest.raises(SystemExit) as exc_info:
|
|
|
|
|
+ COMMANDS["exit"]()
|
|
|
|
|
+ assert exc_info.value.code == 0
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+def test_exit_prints_goodbye(capsys):
|
|
|
|
|
+ with pytest.raises(SystemExit):
|
|
|
|
|
+ COMMANDS["exit"]()
|
|
|
|
|
+ captured = capsys.readouterr()
|
|
|
|
|
+ assert "Goodbye!" in captured.out
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+def test_exit_is_in_registry():
|
|
|
|
|
+ assert "exit" in COMMANDS
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+def test_help_mentions_exit():
|
|
|
|
|
+ result = COMMANDS["help"]()
|
|
|
|
|
+ assert "exit" in result
|