v2.9.0 (#641)
Co-authored-by: Antoine <33425718+anth2o@users.noreply.github.com> Co-authored-by: Bastien <bastien.baret@gmail.com> Co-authored-by: Clément Sirieix <clement.sirieix@mistral.ai> Co-authored-by: Kim-Adeline Miguel <51720070+kimadeline@users.noreply.github.com> Co-authored-by: Mathias Gesbert <mathias.gesbert@mistral.ai> Co-authored-by: Maxime Dolores <maxime.dolores@ext.mistral.ai> Co-authored-by: Michel Thomazo <51709227+michelTho@users.noreply.github.com> Co-authored-by: Nelson PROIA <144663685+Nelson-PROIA@users.noreply.github.com> Co-authored-by: Pierre Rossinès <pierre.rossines@mistral.ai> Co-authored-by: Quentin <quentin.torroba@mistral.ai> Co-authored-by: Robin Gullo <robin.gullo@mistral.ai> Co-authored-by: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
parent
a83c81ecf5
commit
632ea8c032
253 changed files with 13965 additions and 2525 deletions
81
tests/cli/textual_ui/test_event_handler_hooks.py
Normal file
81
tests/cli/textual_ui/test_event_handler_hooks.py
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
import pytest
|
||||
|
||||
import vibe.cli.textual_ui.handlers.event_handler as event_handler_module
|
||||
from vibe.cli.textual_ui.handlers.event_handler import EventHandler
|
||||
from vibe.core.hooks.models import (
|
||||
HookEndEvent,
|
||||
HookMessageSeverity,
|
||||
HookRunEndEvent,
|
||||
HookRunStartEvent,
|
||||
)
|
||||
|
||||
|
||||
class FakeHookRunContainer:
|
||||
def __init__(self) -> None:
|
||||
self.display = False
|
||||
self.remove = AsyncMock()
|
||||
|
||||
async def add_message(self, _widget: object) -> None:
|
||||
self.display = True
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_hook_run_end_removes_empty_container(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
created_containers: list[FakeHookRunContainer] = []
|
||||
|
||||
def make_container() -> FakeHookRunContainer:
|
||||
container = FakeHookRunContainer()
|
||||
created_containers.append(container)
|
||||
return container
|
||||
|
||||
monkeypatch.setattr(event_handler_module, "HookRunContainer", make_container)
|
||||
|
||||
mount_callback = AsyncMock()
|
||||
handler = EventHandler(
|
||||
mount_callback=mount_callback, get_tools_collapsed=lambda: False
|
||||
)
|
||||
|
||||
await handler.handle_event(HookRunStartEvent())
|
||||
await handler.handle_event(HookRunEndEvent())
|
||||
|
||||
assert len(created_containers) == 1
|
||||
created_containers[0].remove.assert_awaited_once()
|
||||
assert handler._hook_run_container is None
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_hook_run_end_keeps_container_with_messages(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
created_containers: list[FakeHookRunContainer] = []
|
||||
|
||||
def make_container() -> FakeHookRunContainer:
|
||||
container = FakeHookRunContainer()
|
||||
created_containers.append(container)
|
||||
return container
|
||||
|
||||
monkeypatch.setattr(event_handler_module, "HookRunContainer", make_container)
|
||||
|
||||
mount_callback = AsyncMock()
|
||||
handler = EventHandler(
|
||||
mount_callback=mount_callback, get_tools_collapsed=lambda: False
|
||||
)
|
||||
|
||||
await handler.handle_event(HookRunStartEvent())
|
||||
await handler.handle_event(
|
||||
HookEndEvent(
|
||||
hook_name="post-turn", status=HookMessageSeverity.OK, content="Hook output"
|
||||
)
|
||||
)
|
||||
await handler.handle_event(HookRunEndEvent())
|
||||
|
||||
assert len(created_containers) == 1
|
||||
created_containers[0].remove.assert_not_awaited()
|
||||
assert created_containers[0].display is True
|
||||
assert handler._hook_run_container is None
|
||||
Loading…
Add table
Add a link
Reference in a new issue