v2.2.0 (#395)
Co-authored-by: Quentin Torroba <quentin.torroba@mistral.ai> Co-authored-by: Clément Siriex <clement.sirieix@mistral.ai> Co-authored-by: Kim-Adeline Miguel <kimadeline.miguel@mistral.ai> Co-authored-by: Michel Thomazo <michel.thomazo@mistral.ai> Co-authored-by: Clément Drouin <clement.drouin@mistral.ai>
This commit is contained in:
parent
51fecc67d9
commit
ec7f3b25ea
107 changed files with 8002 additions and 535 deletions
|
|
@ -74,7 +74,8 @@ def test_copy_selection_to_clipboard_no_notification(
|
|||
del widgets[0].text_selection
|
||||
mock_app.query.return_value = widgets
|
||||
|
||||
copy_selection_to_clipboard(mock_app)
|
||||
result = copy_selection_to_clipboard(mock_app)
|
||||
assert result is None
|
||||
mock_app.notify.assert_not_called()
|
||||
|
||||
|
||||
|
|
@ -87,8 +88,9 @@ def test_copy_selection_to_clipboard_success(
|
|||
)
|
||||
mock_app.query.return_value = [widget]
|
||||
|
||||
copy_selection_to_clipboard(mock_app)
|
||||
result = copy_selection_to_clipboard(mock_app)
|
||||
|
||||
assert result == "selected text"
|
||||
mock_copy_osc52.assert_called_once_with("selected text")
|
||||
mock_app.notify.assert_called_once_with(
|
||||
'"selected text" copied to clipboard',
|
||||
|
|
@ -109,8 +111,9 @@ def test_copy_selection_to_clipboard_failure(
|
|||
|
||||
mock_copy_osc52.side_effect = Exception("OSC52 failed")
|
||||
|
||||
copy_selection_to_clipboard(mock_app)
|
||||
result = copy_selection_to_clipboard(mock_app)
|
||||
|
||||
assert result is None
|
||||
mock_copy_osc52.assert_called_once_with("selected text")
|
||||
mock_app.notify.assert_called_once_with(
|
||||
"Failed to copy - clipboard not available", severity="warning", timeout=3
|
||||
|
|
@ -129,8 +132,9 @@ def test_copy_selection_to_clipboard_multiple_widgets(mock_app: MagicMock) -> No
|
|||
mock_app.query.return_value = [widget1, widget2, widget3]
|
||||
|
||||
with patch("vibe.cli.clipboard._copy_osc52") as mock_copy_osc52:
|
||||
copy_selection_to_clipboard(mock_app)
|
||||
result = copy_selection_to_clipboard(mock_app)
|
||||
|
||||
assert result == "first selection\nsecond selection"
|
||||
mock_copy_osc52.assert_called_once_with("first selection\nsecond selection")
|
||||
mock_app.notify.assert_called_once_with(
|
||||
'"first selection\u23cesecond selection" copied to clipboard',
|
||||
|
|
@ -148,8 +152,9 @@ def test_copy_selection_to_clipboard_preview_shortening(mock_app: MagicMock) ->
|
|||
mock_app.query.return_value = [widget]
|
||||
|
||||
with patch("vibe.cli.clipboard._copy_osc52") as mock_copy_osc52:
|
||||
copy_selection_to_clipboard(mock_app)
|
||||
result = copy_selection_to_clipboard(mock_app)
|
||||
|
||||
assert result == long_text
|
||||
mock_copy_osc52.assert_called_once_with(long_text)
|
||||
notification_call = mock_app.notify.call_args
|
||||
assert notification_call is not None
|
||||
|
|
|
|||
54
tests/cli/test_commands.py
Normal file
54
tests/cli/test_commands.py
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from vibe.cli.commands import Command, CommandRegistry
|
||||
|
||||
|
||||
class TestCommandRegistry:
|
||||
def test_get_command_name_returns_canonical_name_for_alias(self) -> None:
|
||||
registry = CommandRegistry()
|
||||
assert registry.get_command_name("/help") == "help"
|
||||
assert registry.get_command_name("/config") == "config"
|
||||
assert registry.get_command_name("/model") == "config"
|
||||
assert registry.get_command_name("/clear") == "clear"
|
||||
assert registry.get_command_name("/exit") == "exit"
|
||||
|
||||
def test_get_command_name_normalizes_input(self) -> None:
|
||||
registry = CommandRegistry()
|
||||
assert registry.get_command_name(" /help ") == "help"
|
||||
assert registry.get_command_name("/HELP") == "help"
|
||||
|
||||
def test_get_command_name_returns_none_for_unknown(self) -> None:
|
||||
registry = CommandRegistry()
|
||||
assert registry.get_command_name("/unknown") is None
|
||||
assert registry.get_command_name("hello") is None
|
||||
assert registry.get_command_name("") is None
|
||||
|
||||
def test_find_command_returns_command_when_alias_matches(self) -> None:
|
||||
registry = CommandRegistry()
|
||||
cmd = registry.find_command("/help")
|
||||
assert cmd is not None
|
||||
assert cmd.handler == "_show_help"
|
||||
assert isinstance(cmd, Command)
|
||||
|
||||
def test_find_command_returns_none_when_no_match(self) -> None:
|
||||
registry = CommandRegistry()
|
||||
assert registry.find_command("/nonexistent") is None
|
||||
|
||||
def test_find_command_uses_get_command_name(self) -> None:
|
||||
"""find_command and get_command_name stay in sync for same input."""
|
||||
registry = CommandRegistry()
|
||||
for alias in ["/help", "/config", "/clear", "/exit"]:
|
||||
cmd_name = registry.get_command_name(alias)
|
||||
cmd = registry.find_command(alias)
|
||||
if cmd_name is None:
|
||||
assert cmd is None
|
||||
else:
|
||||
assert cmd is not None
|
||||
assert cmd_name in registry.commands
|
||||
assert registry.commands[cmd_name] is cmd
|
||||
|
||||
def test_excluded_commands_not_in_registry(self) -> None:
|
||||
registry = CommandRegistry(excluded_commands=["exit"])
|
||||
assert registry.get_command_name("/exit") is None
|
||||
assert registry.find_command("/exit") is None
|
||||
assert registry.get_command_name("/help") == "help"
|
||||
Loading…
Add table
Add a link
Reference in a new issue