refactor: WebSocketChannel accepts injected http_handler, update all tests
This commit is contained in:
@@ -18,8 +18,10 @@ import pytest
|
||||
|
||||
from nanobot.channels.websocket import (
|
||||
WebSocketChannel,
|
||||
WebSocketConfig,
|
||||
_extract_data_url_mime,
|
||||
)
|
||||
from nanobot.webui.ws_http import GatewayHTTPHandler
|
||||
|
||||
|
||||
def _tiny_png_data_url() -> str:
|
||||
@@ -41,10 +43,19 @@ def _data_url(mime: str, payload: bytes) -> str:
|
||||
def _make_channel() -> WebSocketChannel:
|
||||
bus = MagicMock()
|
||||
bus.publish_inbound = AsyncMock()
|
||||
channel = WebSocketChannel(
|
||||
{"enabled": True, "allowFrom": ["*"], "websocketRequiresToken": False},
|
||||
bus,
|
||||
cfg = {"enabled": True, "allowFrom": ["*"], "websocketRequiresToken": False}
|
||||
parsed = WebSocketConfig.model_validate(cfg)
|
||||
handler = GatewayHTTPHandler(
|
||||
config=parsed,
|
||||
session_manager=None,
|
||||
static_dist_path=None,
|
||||
workspace_path=Path.cwd(),
|
||||
runtime_model_name=None,
|
||||
runtime_surface="browser",
|
||||
runtime_capabilities_overrides=None,
|
||||
bus=bus,
|
||||
)
|
||||
channel = WebSocketChannel(cfg, bus, http_handler=handler)
|
||||
channel._handle_message = AsyncMock() # type: ignore[method-assign]
|
||||
return channel
|
||||
|
||||
|
||||
Reference in New Issue
Block a user