* feat(webui): improve channel setup flows * fix(webui): refine channel setup interactions (NAN-112) * fix(webui): keep email setup sections channel-owned * fix(webui): remove concrete channel details from shared components * refactor(webui): remove unused channel setup resources * fix(webui): finish channel-owned setup boundaries * fix(webui): update channel switches optimistically * test(channels): remove obsolete absence assertions * fix(webui): flatten channel instance settings disclosure * fix(webui): complete channel setup and connection flows * fix(whatsapp): wait for session database release * fix(webui): preserve scrolling channel controls * fix(webui): stage channel connection checks * fix(channels): align verification actions * fix(email): expose connection checks * fix(webui): align channel field actions * fix(email): verify account credentials * fix(wecom): bypass system proxy for websocket * fix(channels): stabilize async connection cleanup * fix(webui): autosave channel credentials * fix(email): make provider presets non-destructive * test(weixin): isolate persisted QR credentials
68 lines
2.2 KiB
Python
68 lines
2.2 KiB
Python
from __future__ import annotations
|
|
|
|
from nanobot.channels.registry import load_channel_plugin
|
|
from nanobot.config.schema import Config
|
|
from nanobot.webui.settings_system import (
|
|
coerce_channel_value,
|
|
save_channel_config_values,
|
|
system_settings_payload,
|
|
update_agent_system_settings,
|
|
)
|
|
|
|
|
|
def test_system_domain_owns_runtime_dto_and_agent_updates(tmp_path) -> None:
|
|
config = Config()
|
|
|
|
changed, restart_required = update_agent_system_settings(
|
|
config,
|
|
{
|
|
"timezone": ["Asia/Shanghai"],
|
|
"tool_hint_max_length": ["120"],
|
|
},
|
|
)
|
|
payload = system_settings_payload(
|
|
config,
|
|
config_path=tmp_path / "config.json",
|
|
version="0.3.0",
|
|
)
|
|
|
|
assert changed is True
|
|
assert restart_required is True
|
|
assert config.agents.defaults.timezone == "Asia/Shanghai"
|
|
assert config.agents.defaults.timezone_mode == "manual"
|
|
assert config.agents.defaults.tool_hint_max_length == 120
|
|
assert payload["runtime"]["config_path"] == str(tmp_path / "config.json")
|
|
assert payload["version"] == {"current": "0.3.0"}
|
|
assert payload["docs"]["version"] == "0.3.0"
|
|
assert set(payload) == {"runtime", "runtime_config", "usage", "advanced", "version", "docs"}
|
|
|
|
|
|
def test_system_domain_validates_channel_field_values() -> None:
|
|
assert coerce_channel_value("allow_from", "alice, bob", "list") == [
|
|
"alice",
|
|
"bob",
|
|
]
|
|
assert coerce_channel_value("enabled", "yes", "bool") is True
|
|
assert coerce_channel_value("port", "8765", "int") == 8765
|
|
assert coerce_channel_value("delay", "0.6", "float") == 0.6
|
|
assert coerce_channel_value("overrides", '{"123": "open"}', "json") == {
|
|
"123": "open"
|
|
}
|
|
assert coerce_channel_value("token", None, "secret") == ""
|
|
|
|
|
|
def test_channel_secret_is_cleared_only_by_explicit_null() -> None:
|
|
config = Config.model_validate({
|
|
"channels": {"matrix": {"password": "saved-password"}},
|
|
})
|
|
|
|
saved = save_channel_config_values(
|
|
config,
|
|
"matrix",
|
|
{"channels.matrix.password": None},
|
|
load_channel_plugin=load_channel_plugin,
|
|
)
|
|
|
|
assert saved == ["channels.matrix.password"]
|
|
assert config.channels.matrix["password"] == ""
|