mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-04-02 17:32:39 +00:00
- Move onboard-related tests from test_commands.py and test_config_migration.py to new test_onboard_logic.py for better organization - Add comprehensive unit tests for: - _merge_missing_defaults recursive config merging - _get_field_type_info type extraction - _get_field_display_name human-readable name generation - _format_value display formatting - sync_workspace_templates file synchronization - Remove unused dev dependencies (matrix-nio, mistune, nh3) from pyproject.toml
53 lines
1.5 KiB
Python
53 lines
1.5 KiB
Python
import json
|
|
|
|
from nanobot.config.loader import load_config, save_config
|
|
|
|
|
|
def test_load_config_keeps_max_tokens_and_warns_on_legacy_memory_window(tmp_path) -> None:
|
|
config_path = tmp_path / "config.json"
|
|
config_path.write_text(
|
|
json.dumps(
|
|
{
|
|
"agents": {
|
|
"defaults": {
|
|
"maxTokens": 1234,
|
|
"memoryWindow": 42,
|
|
}
|
|
}
|
|
}
|
|
),
|
|
encoding="utf-8",
|
|
)
|
|
|
|
config = load_config(config_path)
|
|
|
|
assert config.agents.defaults.max_tokens == 1234
|
|
assert config.agents.defaults.context_window_tokens == 65_536
|
|
assert config.agents.defaults.should_warn_deprecated_memory_window is True
|
|
|
|
|
|
def test_save_config_writes_context_window_tokens_but_not_memory_window(tmp_path) -> None:
|
|
config_path = tmp_path / "config.json"
|
|
config_path.write_text(
|
|
json.dumps(
|
|
{
|
|
"agents": {
|
|
"defaults": {
|
|
"maxTokens": 2222,
|
|
"memoryWindow": 30,
|
|
}
|
|
}
|
|
}
|
|
),
|
|
encoding="utf-8",
|
|
)
|
|
|
|
config = load_config(config_path)
|
|
save_config(config, config_path)
|
|
saved = json.loads(config_path.read_text(encoding="utf-8"))
|
|
defaults = saved["agents"]["defaults"]
|
|
|
|
assert defaults["maxTokens"] == 2222
|
|
assert defaults["contextWindowTokens"] == 65_536
|
|
assert "memoryWindow" not in defaults
|