Break tool config schema import cycle

This commit is contained in:
chengyongru
2026-06-13 21:59:07 +08:00
committed by Xubin Ren
parent 7ff8e02eaf
commit 3a221d74cf
9 changed files with 62 additions and 59 deletions
-44
View File
@@ -352,50 +352,6 @@ def test_mcp_wrappers_not_discoverable():
assert MCPPromptWrapper._plugin_discoverable is False
# --- Task 8: Config round-trip tests ---
def test_config_round_trip():
"""Verify config serialization is unchanged after moving config classes."""
from nanobot.config.schema import Config
config_dict = {
"tools": {
"web": {"enable": True, "search": {"provider": "brave", "api_key": "test"}},
"exec": {"enable": False, "timeout": 120, "pathPrepend": "/venv/bin"},
"my": {"allowSet": True},
"imageGeneration": {"enabled": True, "provider": "openrouter"},
}
}
config = Config.model_validate(config_dict)
dumped = config.model_dump(mode="json", by_alias=True)
assert dumped["tools"]["my"]["allowSet"] is True
assert dumped["tools"]["imageGeneration"]["enabled"] is True
assert dumped["tools"]["exec"]["pathPrepend"] == "/venv/bin"
assert config.tools.exec.enable is False
assert config.tools.exec.timeout == 120
assert config.tools.exec.path_prepend == "/venv/bin"
assert config.tools.web.search.provider == "brave"
def test_config_defaults():
"""Verify default values match the original hardcoded schema."""
from nanobot.config.schema import Config
config = Config.model_validate({})
assert config.tools.exec.enable is True
assert config.tools.exec.timeout == 60
assert config.tools.exec.path_prepend == ""
assert config.tools.web.enable is True
assert config.tools.web.search.provider == "duckduckgo"
assert config.tools.my.enable is True
assert config.tools.my.allow_set is False
assert config.tools.image_generation.enabled is False
assert config.tools.cli_apps.enable is True
assert config.tools.restrict_to_workspace is False
# --- Task 10: Integration test ---