refactor(bus): type outbound runtime events
This commit is contained in:
@@ -3,6 +3,7 @@ from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from nanobot.bus.outbound_events import ProgressEvent, RetryWaitEvent
|
||||
from nanobot.cli import commands
|
||||
|
||||
|
||||
@@ -14,7 +15,8 @@ async def test_interactive_retry_wait_is_rendered_as_progress_even_when_progress
|
||||
channels_config = SimpleNamespace(send_progress=False, send_tool_hints=False)
|
||||
msg = SimpleNamespace(
|
||||
content="Model request failed, retry in 2s (attempt 1).",
|
||||
metadata={"_retry_wait": True},
|
||||
event=RetryWaitEvent(content="Model request failed, retry in 2s (attempt 1)."),
|
||||
metadata={},
|
||||
)
|
||||
|
||||
async def fake_print(text: str, active_thinking: object | None, renderer=None) -> None:
|
||||
@@ -40,7 +42,8 @@ async def test_reasoning_displayed_when_show_reasoning_enabled():
|
||||
)
|
||||
msg = SimpleNamespace(
|
||||
content="Let me think about this...",
|
||||
metadata={"_progress": True, "_reasoning": True},
|
||||
event=ProgressEvent(content="Let me think about this...", reasoning=True),
|
||||
metadata={},
|
||||
)
|
||||
|
||||
with patch("nanobot.cli.commands._print_cli_reasoning", side_effect=lambda t, th, r=None: calls.append(t)):
|
||||
@@ -59,7 +62,8 @@ async def test_reasoning_delta_displayed_when_show_reasoning_enabled():
|
||||
)
|
||||
msg = SimpleNamespace(
|
||||
content="I should search first.",
|
||||
metadata={"_progress": True, "_reasoning_delta": True},
|
||||
event=ProgressEvent(content="I should search first.", reasoning_delta=True),
|
||||
metadata={},
|
||||
)
|
||||
|
||||
with patch("nanobot.cli.commands._print_cli_reasoning", side_effect=lambda t, th, r=None: calls.append(t)):
|
||||
@@ -81,7 +85,8 @@ async def test_reasoning_delta_buffers_until_sentence_boundary():
|
||||
first = await commands._maybe_print_interactive_progress(
|
||||
SimpleNamespace(
|
||||
content="The",
|
||||
metadata={"_progress": True, "_reasoning_delta": True},
|
||||
event=ProgressEvent(content="The", reasoning_delta=True),
|
||||
metadata={},
|
||||
),
|
||||
None,
|
||||
channels_config,
|
||||
@@ -90,7 +95,8 @@ async def test_reasoning_delta_buffers_until_sentence_boundary():
|
||||
second = await commands._maybe_print_interactive_progress(
|
||||
SimpleNamespace(
|
||||
content=" user asked.",
|
||||
metadata={"_progress": True, "_reasoning_delta": True},
|
||||
event=ProgressEvent(content=" user asked.", reasoning_delta=True),
|
||||
metadata={},
|
||||
),
|
||||
None,
|
||||
channels_config,
|
||||
@@ -114,7 +120,8 @@ async def test_reasoning_end_flushes_buffered_delta():
|
||||
delta = await commands._maybe_print_interactive_progress(
|
||||
SimpleNamespace(
|
||||
content="The user asked",
|
||||
metadata={"_progress": True, "_reasoning_delta": True},
|
||||
event=ProgressEvent(content="The user asked", reasoning_delta=True),
|
||||
metadata={},
|
||||
),
|
||||
None,
|
||||
channels_config,
|
||||
@@ -123,7 +130,8 @@ async def test_reasoning_end_flushes_buffered_delta():
|
||||
end = await commands._maybe_print_interactive_progress(
|
||||
SimpleNamespace(
|
||||
content="",
|
||||
metadata={"_progress": True, "_reasoning_end": True},
|
||||
event=ProgressEvent(reasoning_end=True),
|
||||
metadata={},
|
||||
),
|
||||
None,
|
||||
channels_config,
|
||||
@@ -143,7 +151,8 @@ async def test_reasoning_hidden_when_show_reasoning_disabled():
|
||||
)
|
||||
msg = SimpleNamespace(
|
||||
content="Let me think about this...",
|
||||
metadata={"_progress": True, "_reasoning": True},
|
||||
event=ProgressEvent(content="Let me think about this...", reasoning=True),
|
||||
metadata={},
|
||||
)
|
||||
|
||||
with patch("nanobot.cli.commands._print_cli_reasoning") as mock_reasoning:
|
||||
@@ -162,7 +171,8 @@ async def test_non_reasoning_progress_not_affected_by_show_reasoning():
|
||||
)
|
||||
msg = SimpleNamespace(
|
||||
content="working on it...",
|
||||
metadata={"_progress": True},
|
||||
event=ProgressEvent(content="working on it..."),
|
||||
metadata={},
|
||||
)
|
||||
|
||||
async def fake_print(text: str, thinking=None, renderer=None):
|
||||
@@ -185,7 +195,8 @@ async def test_reasoning_shown_when_send_progress_disabled():
|
||||
)
|
||||
msg = SimpleNamespace(
|
||||
content="Let me think about this...",
|
||||
metadata={"_progress": True, "_reasoning": True},
|
||||
event=ProgressEvent(content="Let me think about this...", reasoning=True),
|
||||
metadata={},
|
||||
)
|
||||
|
||||
with patch(
|
||||
|
||||
Reference in New Issue
Block a user