b4fbd6fe9f
Deploy Site / deploy-vercel (push) Has been skipped
Deploy Site / deploy-docs (push) Has been skipped
Build Skills Index / build-index (push) Has been skipped
CI / Deny unrelated histories (push) Has been skipped
CI / Detect affected areas (push) Successful in 27m35s
CI / OSV scan (push) Failing after 4s
CI / Build&Test Docker image (push) Successful in 9s
CI / Supply-chain scan (push) Has been skipped
CI / Lint Docker scripts (push) Failing after 5m13s
CI / Check contributors (push) Failing after 12m8s
CI / Docs Site (push) Failing after 12m8s
CI / TypeScript (push) Failing after 12m8s
CI / Python lints (push) Failing after 12m9s
CI / Python tests (push) Failing after 12m9s
CI / Check uv.lock (push) Failing after 23m22s
CI / CI timing report (push) Has been cancelled
Build Skills Index / trigger-deploy (push) Has been cancelled
CI / All required checks pass (push) Has been cancelled
68 lines
1.8 KiB
Python
68 lines
1.8 KiB
Python
"""Tests for tui_gateway.render — rendering bridge fallback behavior."""
|
|
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
from tui_gateway.render import make_stream_renderer, render_diff, render_message
|
|
|
|
|
|
def _stub_rich(mock_mod):
|
|
return patch.dict("sys.modules", {"agent.rich_output": mock_mod})
|
|
|
|
|
|
def _no_rich():
|
|
return patch.dict("sys.modules", {"agent.rich_output": None})
|
|
|
|
|
|
# ── render_message ───────────────────────────────────────────────────
|
|
|
|
|
|
def test_render_message_none_without_module():
|
|
with _no_rich():
|
|
assert render_message("hello") is None
|
|
|
|
|
|
def test_render_message_formatted():
|
|
mod = MagicMock()
|
|
mod.format_response.return_value = "<b>hi</b>"
|
|
|
|
with _stub_rich(mod):
|
|
assert render_message("hi", 100) == "<b>hi</b>"
|
|
|
|
|
|
def test_render_message_type_error_fallback():
|
|
mod = MagicMock()
|
|
mod.format_response.side_effect = [TypeError, "fallback"]
|
|
|
|
with _stub_rich(mod):
|
|
assert render_message("hi") == "fallback"
|
|
|
|
|
|
def test_render_message_exception_returns_none():
|
|
mod = MagicMock()
|
|
mod.format_response.side_effect = RuntimeError
|
|
|
|
with _stub_rich(mod):
|
|
assert render_message("hi") is None
|
|
|
|
|
|
# ── render_diff / make_stream_renderer ───────────────────────────────
|
|
|
|
|
|
def test_render_diff_none_without_module():
|
|
with _no_rich():
|
|
assert render_diff("+line") is None
|
|
|
|
|
|
def test_stream_renderer_none_without_module():
|
|
with _no_rich():
|
|
assert make_stream_renderer() is None
|
|
|
|
|
|
def test_stream_renderer_returns_instance():
|
|
renderer = MagicMock()
|
|
mod = MagicMock()
|
|
mod.StreamingRenderer.return_value = renderer
|
|
|
|
with _stub_rich(mod):
|
|
assert make_stream_renderer(120) is renderer
|