test: remove obsolete nonexistence checks

This commit is contained in:
chengyongru authored and chengyongru committed 2026-09-05 23:58:38 +08:00
1 parent c08172a641
commit 3495281282
24 files changed
+8 -407

No files matched your search

@@ -4,7 +4,7 @@ import pytest
from nanobot.channels.email import validation as email_validation
from nanobot.channels.validation import validate_channel_config
from nanobot.config.loader import load_config, save_config
from nanobot.config.loader import save_config
from nanobot.config.schema import Config
@@ -14,6 +14,7 @@ def test_validate_email_presets_are_checked_without_saving(
) -> None:
config_path = tmp_path / "config.json"
save_config(Config(), config_path)
original_config = config_path.read_bytes()
monkeypatch.setattr("nanobot.config.loader._current_config_path", config_path)
monkeypatch.setattr(email_validation, "probe_tcp", lambda *_args, **_kwargs: None)
@@ -32,7 +33,7 @@ def test_validate_email_presets_are_checked_without_saving(
assert result["status"] == "connected"
assert result["can_enable"] is True
assert not hasattr(load_config(config_path).channels, "email")
assert config_path.read_bytes() == original_config
def test_validate_email_blocks_private_targets_when_local_access_is_disabled(
@@ -341,26 +341,6 @@ async def test_sessions_list_and_thread_restore_transcript_without_canonical_fil
await server_task
@pytest.mark.asyncio
async def test_legacy_session_messages_route_is_not_exposed(
bus: MagicMock, tmp_path: Path
) -> None:
sm = _seed_session(tmp_path, key="websocket:legacy")
channel = _ch(bus, session_manager=sm, port=29919)
server_task = asyncio.create_task(channel.start())
try:
token = channel.gateway.tokens.issue_api_token(300)
response = await _http_get(
"http://127.0.0.1:29919/api/sessions/websocket:legacy/messages",
headers={"Authorization": f"Bearer {token}"},
)
assert response.status_code == 404
finally:
await channel.stop()
await server_task
@pytest.mark.asyncio
async def test_session_automations_route_filters_by_webui_session(
bus: MagicMock, tmp_path: Path
@@ -157,11 +157,9 @@ class _FailingConnectLoginClient(_FakeLoginClient):
return asyncio.create_task(fail())
def test_default_config_has_no_bridge_fields() -> None:
def test_default_config_uses_native_database_path() -> None:
config = WhatsAppChannel.default_config()
assert "bridgeUrl" not in config
assert "bridgeToken" not in config
assert config["databasePath"] == ""
@@ -9,7 +9,6 @@ def test_weather_skill_uses_windows_safe_single_today_request() -> None:
assert "bare `curl` may resolve to `Invoke-WebRequest`" in normalized
assert "https://wttr.in/London?1&m" in content
assert 'curl.exe -s "https://wttr.in/Berlin.png" -o weather.png' in content
assert "/tmp/weather.png" not in content
assert (
"Do not fetch current conditions separately when a today or forecast "
"request already includes them."
-3
View File
@@ -218,17 +218,14 @@ class TestBundledToolContract:
assert "Do not use `exec` as a universal workaround" in content
assert "## File and Coding Workflows" in content
assert "`grep` returns matches with five context lines by default" in content
assert 'defaults to `output_mode="files_with_matches"`' not in content
assert "apply_patch" in content
assert "acceptance criteria into concrete checks" in content
assert "visual evidence reaches the model" in content
assert "clear user request as authorization" in content
assert "Never invent missing records or measurements" in content
assert "scientific fitting" not in content
assert "## Web and External Information" in content
assert "## Messaging and Media" in content
assert "## Scheduling and Background Work" in content
assert "pure coding" not in content.lower()
def test_tool_contract_is_injected_without_workspace_file(self, tmp_path):
builder = _builder(tmp_path)
-25
View File
@@ -80,8 +80,6 @@ def test_system_prompt_reflects_current_dream_memory_contract(tmp_path) -> None:
assert "memory/history.jsonl" in prompt
assert "automatically managed by Dream" in prompt
assert "do not edit directly" in prompt
assert "memory/HISTORY.md" not in prompt
assert "write important facts here" not in prompt
def test_provider_context_appended_after_user_content(tmp_path) -> None:
@@ -137,28 +135,6 @@ def test_execution_rules_reach_existing_workspace_soul(tmp_path) -> None:
assert soul_path.read_text(encoding="utf-8") == legacy_soul
def test_identity_has_no_behavioral_instructions(tmp_path) -> None:
"""Identity template should not contain behavioral rules or hardcoded name."""
workspace = _make_workspace(tmp_path)
builder = ContextBuilder(workspace)
identity = builder._get_identity(channel=None)
assert "You are nanobot" not in identity
assert "Act, don't narrate" not in identity
assert "Execution Rules" not in identity
def test_system_prompt_does_not_warn_about_message_time_markers(tmp_path) -> None:
"""Parroting is prevented by not annotating assistant turns in history;
no prompt-level warning about ``[Message Time: ...]`` is needed."""
workspace = _make_workspace(tmp_path)
builder = ContextBuilder(workspace)
prompt = builder.build_system_prompt()
assert "Message Time" not in prompt
def test_default_soul_template_keeps_execution_policy_in_tool_contract() -> None:
"""SOUL owns personality while the always-injected contract owns execution policy."""
soul = (pkg_files("nanobot") / "templates" / "SOUL.md").read_text(encoding="utf-8")
@@ -256,7 +232,6 @@ def test_fresh_workspace_omits_default_prompt_scaffolding(tmp_path) -> None:
assert "## USER.md" not in prompt
assert "8281248569" not in prompt
assert "(your name)" not in prompt
assert "apt/brew" not in prompt
assert prompt.count("Do not use the 'message' tool for normal replies") == 1
@@ -264,7 +264,6 @@ def test_refresh_clears_preset_when_new_default_has_same_snapshot_signature() ->
assert refreshed is not None
assert resolver.model_preset is None
assert resolver.runtime.model_preset is None
assert "_active_preset" not in resolver.__dict__
def test_resolver_refreshes_provider_generation_for_next_default_turn() -> None:
+1 -32
View File
@@ -29,7 +29,7 @@ def _provider(default_model: str, max_tokens: int = 123) -> MagicMock:
return provider
def test_provider_refresh_updates_only_runtime_resolver(tmp_path: Path) -> None:
def test_provider_refresh_updates_runtime_resolver(tmp_path: Path) -> None:
old_provider = _provider("old-model")
new_provider = _provider("new-model", max_tokens=456)
loop = AgentLoop(
@@ -53,36 +53,6 @@ def test_provider_refresh_updates_only_runtime_resolver(tmp_path: Path) -> None:
assert loop.provider is new_provider
assert loop.model == "new-model"
assert loop.context_window_tokens == 2000
assert not hasattr(loop.runner, "provider")
assert not hasattr(loop.subagents, "provider")
assert not hasattr(loop.subagents, "model")
assert not hasattr(loop.subagents.runner, "provider")
assert not hasattr(loop.consolidator, "provider")
assert not hasattr(loop.consolidator, "model")
assert not hasattr(loop.consolidator, "context_window_tokens")
assert not hasattr(loop.consolidator, "max_completion_tokens")
def test_loop_has_no_mutable_runtime_mirrors_or_legacy_snapshot_api(tmp_path: Path) -> None:
loop = AgentLoop(
bus=MessageBus(),
provider=_provider("test-model"),
workspace=tmp_path,
model="test-model",
context_window_tokens=1000,
)
assert {
"provider",
"model",
"context_window_tokens",
"model_presets",
"_active_preset",
"_provider_signature",
"_max_messages",
}.isdisjoint(loop.__dict__)
assert not hasattr(loop, "_apply_provider_snapshot")
assert not hasattr(loop, "_build_model_preset_snapshot")
def test_llm_runtime_refreshes_provider_snapshot(tmp_path: Path) -> None:
@@ -108,7 +78,6 @@ def test_llm_runtime_refreshes_provider_snapshot(tmp_path: Path) -> None:
assert runtime.provider is new_provider
assert runtime.model == "new-model"
assert loop.provider is new_provider
assert not hasattr(loop.runner, "provider")
def test_llm_runtime_surfaces_invalidated_config_errors(tmp_path: Path) -> None:
-12
View File
@@ -69,12 +69,8 @@ def test_model_preset_setter_updates_state(tmp_path) -> None:
assert runtime.generation.temperature == 0.5
assert runtime.generation.max_tokens == 4096
assert runtime.generation.reasoning_effort == "low"
assert not hasattr(loop.subagents, "model")
assert not hasattr(loop.consolidator, "model")
assert not hasattr(loop.consolidator, "context_window_tokens")
assert loop.llm_runtime().model == "openai/gpt-4.1"
assert loop.llm_runtime().context_window_tokens == 32_768
assert not hasattr(loop.consolidator, "max_completion_tokens")
assert loop.llm_runtime().generation.max_tokens == 4096
@@ -122,13 +118,8 @@ def test_model_preset_setter_replaces_provider_from_snapshot(tmp_path) -> None:
loop.set_model_preset("deep")
assert loop.provider is new_provider
assert not hasattr(loop.runner, "provider")
assert not hasattr(loop.subagents, "provider")
assert not hasattr(loop.subagents.runner, "provider")
assert not hasattr(loop.consolidator, "provider")
assert loop.model == "anthropic/claude-opus-4-5"
assert loop.context_window_tokens == 200_000
assert not hasattr(loop.consolidator, "max_completion_tokens")
assert loop.llm_runtime().generation.max_tokens == 2048
@@ -151,10 +142,7 @@ def test_model_preset_setter_failure_leaves_old_state(tmp_path) -> None:
assert loop.model_preset is None
assert loop.model == "base-model"
assert not hasattr(loop.subagents, "model")
assert not hasattr(loop.consolidator, "model")
assert loop.context_window_tokens == 1000
assert not hasattr(loop.consolidator, "max_completion_tokens")
assert loop.llm_runtime().generation.max_tokens == 123
-16
View File
@@ -102,20 +102,6 @@ class TestSubagentStatus:
assert s.error is None
# ---------------------------------------------------------------------------
# Runtime ownership
# ---------------------------------------------------------------------------
class TestRuntimeOwnership:
def test_manager_has_no_provider_model_mirrors(self, tmp_path):
sm = _manager(tmp_path)
assert not hasattr(sm, "provider")
assert not hasattr(sm, "model")
assert not hasattr(sm, "context_window_tokens")
assert not hasattr(sm.runner, "provider")
class TestLegacyCompatibility:
def test_accepts_exported_legacy_constructor_positionally(self, tmp_path):
provider = MagicMock(spec=LLMProvider)
@@ -132,8 +118,6 @@ class TestLegacyCompatibility:
assert sm.workspace == tmp_path
assert sm.max_tool_result_chars == 16_000
assert not hasattr(sm, "provider")
assert not hasattr(sm, "model")
@pytest.mark.asyncio
async def test_legacy_spawn_captures_runtime_at_admission(self, tmp_path):
@@ -45,7 +45,6 @@ def test_agent_loop_assembles_my_tool_with_runtime_control(tmp_path: Path) -> No
assert isinstance(tool._runtime_control, RuntimeControl)
assert isinstance(tool._runtime_control, AgentRuntimeControl)
assert tool._runtime_control is not loop
assert not hasattr(tool, "_runtime_state")
def test_runtime_snapshot_has_exact_allowlist_and_redacts_secrets(tmp_path: Path) -> None:
-13
View File
@@ -83,19 +83,6 @@ _SINGLE_PLUGIN = ChannelPlugin(
)
def test_management_contract_is_not_declared_on_runtime_base_class() -> None:
management_hooks = {
"feature_instances",
"instance_specs",
"runtime_name",
"supports_multiple_instances",
"update_instance_config",
}
assert management_hooks.isdisjoint(BaseChannel.__dict__.keys())
assert "refresh_feature_metadata" in BaseChannel.__dict__
def test_multi_instance_support_is_declared_by_management_spec() -> None:
assert _SINGLE_PLUGIN.management.multi_instance is False
assert load_channel_plugin("feishu").management.multi_instance is True
+1 -3
View File
@@ -265,10 +265,8 @@ def test_channels_config_getattr_returns_extra():
assert section["enabled"] is True
def test_channels_config_has_no_per_channel_fields():
"""After decoupling, ChannelsConfig has no explicit channel fields."""
def test_channels_config_keeps_shared_delivery_defaults():
cfg = ChannelsConfig()
assert not hasattr(cfg, "telegram")
assert cfg.send_progress is True
assert cfg.send_tool_hints is True
assert cfg.extract_document_text is True
-23
View File
@@ -98,7 +98,6 @@ def test_every_channel_is_a_self_contained_package() -> None:
channel_dir = Path(channel_setup_module.__file__).parent
package_names = {path.parent.name for path in channel_dir.glob("*/manifest.py")}
assert not hasattr(channel_setup_module, "CHANNEL_SETUP_SPECS")
assert package_names == EXPECTED_CHANNELS
assert set(discover_plugins()) == EXPECTED_CHANNELS
for name in EXPECTED_CHANNELS:
@@ -106,7 +105,6 @@ def test_every_channel_is_a_self_contained_package() -> None:
assert (package_dir / "__init__.py").is_file()
assert (package_dir / "manifest.py").is_file()
assert (package_dir / "runtime.py").is_file()
assert not (channel_dir / f"{name}.py").exists()
plugin = load_channel_package(name)
assert plugin is not None
@@ -165,27 +163,6 @@ def test_channel_manifests_only_import_contract_modules() -> None:
assert not unexpected, f"{name} imports runtime dependencies: {unexpected}"
def test_runtime_classes_do_not_declare_persisted_management_hooks() -> None:
channel_dir = Path(channel_setup_module.__file__).parent
management_hooks = {
"feature_instances",
"instance_specs",
"runtime_name",
"supports_multiple_instances",
"update_instance_config",
}
for name in EXPECTED_CHANNELS:
tree = ast.parse((channel_dir / name / "runtime.py").read_text(encoding="utf-8"))
declared = {
item.name
for node in tree.body
if isinstance(node, ast.ClassDef)
for item in node.body
if isinstance(item, (ast.FunctionDef, ast.AsyncFunctionDef))
}
assert declared.isdisjoint(management_hooks), f"{name} runtime owns {declared & management_hooks}"
def test_feishu_package_manifest_owns_runtime_and_webui_metadata() -> None:
plugin = load_channel_package("feishu")
-136
View File
@@ -17,142 +17,6 @@ def _fake_resolve(host: str, results: list[str]):
return _resolver
def test_load_config_keeps_max_tokens_and_ignores_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 == 200_000
assert not hasattr(config.agents.defaults, "memory_window")
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"] == 200_000
assert "memoryWindow" not in defaults
def test_onboard_does_not_crash_with_legacy_memory_window(tmp_path, monkeypatch) -> None:
config_path = tmp_path / "config.json"
workspace = tmp_path / "workspace"
config_path.write_text(
json.dumps(
{
"agents": {
"defaults": {
"maxTokens": 3333,
"memoryWindow": 50,
}
}
}
),
encoding="utf-8",
)
monkeypatch.setattr("nanobot.config.loader.get_config_path", lambda: config_path)
monkeypatch.setattr("nanobot.cli.commands.get_workspace_path", lambda _workspace=None: workspace)
from typer.testing import CliRunner
from nanobot.cli.commands import app
runner = CliRunner()
result = runner.invoke(app, ["onboard"], input="n\n")
assert result.exit_code == 0
@pytest.mark.parametrize("field_name", ["maxMessages", "max_messages"])
def test_load_config_ignores_legacy_max_messages(tmp_path, field_name) -> None:
config_path = tmp_path / "config.json"
config_path.write_text(
json.dumps({"agents": {"defaults": {field_name: 25, "maxTokens": 1234}}}),
encoding="utf-8",
)
config = load_config(config_path)
assert config.agents.defaults.max_tokens == 1234
assert not hasattr(config.agents.defaults, "max_messages")
def test_save_config_drops_legacy_max_messages(tmp_path) -> None:
config_path = tmp_path / "config.json"
config_path.write_text(
json.dumps({"agents": {"defaults": {"maxMessages": 25}}}),
encoding="utf-8",
)
config = load_config(config_path)
save_config(config, config_path)
saved = json.loads(config_path.read_text(encoding="utf-8"))
assert "maxMessages" not in saved["agents"]["defaults"]
assert "max_messages" not in saved["agents"]["defaults"]
@pytest.mark.parametrize("field_name", ["failOnToolError", "fail_on_tool_error"])
def test_load_config_ignores_removed_fail_on_tool_error(tmp_path, field_name) -> None:
config_path = tmp_path / "config.json"
config_path.write_text(
json.dumps({"agents": {"defaults": {field_name: True, "maxTokens": 1234}}}),
encoding="utf-8",
)
config = load_config(config_path)
assert config.agents.defaults.max_tokens == 1234
assert not hasattr(config.agents.defaults, "fail_on_tool_error")
def test_save_config_drops_removed_fail_on_tool_error(tmp_path) -> None:
config_path = tmp_path / "config.json"
config_path.write_text(
json.dumps({"agents": {"defaults": {"failOnToolError": True}}}),
encoding="utf-8",
)
config = load_config(config_path)
save_config(config, config_path)
saved = json.loads(config_path.read_text(encoding="utf-8"))
assert "failOnToolError" not in saved["agents"]["defaults"]
assert "fail_on_tool_error" not in saved["agents"]["defaults"]
def test_onboard_refresh_backfills_missing_channel_fields(tmp_path, monkeypatch) -> None:
from nanobot.channels.plugin import load_channel_package
-19
View File
@@ -52,22 +52,3 @@ def test_dream_config_uses_model_override_name_and_accepts_legacy_model() -> Non
assert cfg.model_override == "openrouter/sonnet"
assert dumped["modelOverride"] == "openrouter/sonnet"
assert "model" not in dumped
def test_dream_config_ignores_retired_noop_fields() -> None:
cfg = DreamConfig.model_validate(
{
"maxBatchSize": 99,
"maxIterations": 99,
"annotateLineAges": False,
}
)
dumped = cfg.model_dump(by_alias=True)
assert not hasattr(cfg, "max_batch_size")
assert not hasattr(cfg, "max_iterations")
assert not hasattr(cfg, "annotate_line_ages")
assert "maxBatchSize" not in dumped
assert "maxIterations" not in dumped
assert "annotateLineAges" not in dumped
-9
View File
@@ -13,12 +13,3 @@ def test_gateway_restart_mode_accepts_camel_alias():
def test_gateway_restart_mode_rejects_unknown_value():
with pytest.raises(ValueError):
GatewayConfig(restart_mode="service")
def test_heartbeat_ignores_removed_retention_limit():
config = Config.model_validate(
{"gateway": {"heartbeat": {"keepRecentMessages": 8}}}
)
heartbeat = config.model_dump(by_alias=True)["gateway"]["heartbeat"]
assert "keepRecentMessages" not in heartbeat
-14
View File
@@ -275,20 +275,6 @@ def test_model_presets_accepts_camel_case_root_key() -> None:
assert config.model_presets["fast"].provider == "openai"
def test_legacy_model_preset_label_is_ignored() -> None:
config = Config.model_validate({
"modelPresets": {
"gpt-5-6-sol": {
"label": "Codex",
"model": "openai-codex/gpt-5.6-luna",
}
}
})
assert set(config.model_presets) == {"gpt-5-6-sol"}
assert "label" not in config.model_presets["gpt-5-6-sol"].model_dump()
@pytest.mark.parametrize(
"model_presets",
[
-6
View File
@@ -1,18 +1,12 @@
import json
from unittest.mock import MagicMock
import nanobot.session as session_api
from nanobot.providers.base import ProviderConversationState
from nanobot.session import Session, SessionManager
from nanobot.session.manager import SessionStore
from nanobot.session.model_selection import SESSION_MODEL_PRESET_METADATA_KEY
def test_store_types_are_not_public_session_api() -> None:
assert not hasattr(session_api, "SessionStore")
assert not hasattr(session_api, "JsonlSessionStore")
def test_manager_delegates_persistence_to_store(tmp_path) -> None:
stored = Session(key="cli:test")
stored.add_message("user", "hello")
-10
View File
@@ -472,13 +472,6 @@ async def test_ephemeral_run_does_not_invoke_persisted_turn_callback(tmp_path):
assert seen == []
def test_runtime_client_does_not_expose_generic_event_subscription():
from nanobot.sdk.clients import RuntimeClient
assert hasattr(RuntimeClient, "on_session_turn_persisted")
assert not hasattr(RuntimeClient, "subscribe")
def test_import_from_top_level():
import nanobot
@@ -742,7 +735,6 @@ async def test_run_model_overrides_can_overlap_without_default_mutation(tmp_path
config_path = _write_config(tmp_path)
bot = Nanobot.from_config(config_path, workspace=tmp_path)
assert not hasattr(bot, "_runtime_overrides")
original_runtime = bot._loop.runtime_resolver.runtime
active_runs: list[tuple[str, str]] = []
first_entered = asyncio.Event()
@@ -824,7 +816,6 @@ async def test_run_model_override_is_per_run_without_default_mutation(tmp_path):
async def fake_process_direct(message, *, session_key, hooks, runtime):
assert runtime is override_runtime
assert not hasattr(bot._loop.runner, "provider")
assert runtime.model == "openai/gpt-4.1-mini"
assert runtime.context_window_tokens == 4096
assert bot._loop.runtime_resolver.runtime is original_runtime
@@ -840,7 +831,6 @@ async def test_run_model_override_is_per_run_without_default_mutation(tmp_path):
model_preset=None,
config=bot._config,
)
assert not hasattr(bot._loop.runner, "provider")
assert bot._loop.runtime_resolver.runtime is original_runtime
+1 -17
View File
@@ -1,25 +1,9 @@
import inspect
from types import SimpleNamespace
def test_sanitize_persisted_blocks_truncate_text_shadowing_regression() -> None:
"""Regression: avoid bool param shadowing imported truncate_text.
Buggy behavior (historical):
- loop.py imports `truncate_text` from helpers
- `_sanitize_persisted_blocks(..., truncate_text: bool=...)` uses same name
- when called with `truncate_text=True`, function body executes `truncate_text(text, ...)`
which resolves to bool and raises `TypeError: 'bool' object is not callable`.
This test asserts the fixed API exists and truncation works without raising.
"""
def test_sanitize_persisted_blocks_truncates_text() -> None:
from nanobot.agent.loop import AgentLoop
sig = inspect.signature(AgentLoop._sanitize_persisted_blocks)
assert "should_truncate_text" in sig.parameters
assert "truncate_text" not in sig.parameters
dummy = SimpleNamespace(max_tool_result_chars=5)
content = [{"type": "text", "text": "0123456789"}]
-8
View File
@@ -40,10 +40,6 @@ class TestReadDescriptionFix:
tool = ReadFileTool()
assert "image" in tool.description.lower()
def test_description_no_longer_says_cannot_read_images(self):
tool = ReadFileTool()
assert "cannot read binary files or images" not in tool.description.lower()
# ---------------------------------------------------------------------------
# Read deduplication
@@ -542,7 +538,3 @@ class TestReadDescriptionUpdate:
tool = ReadFileTool()
desc = tool.description.lower()
assert "document" in desc or "docx" in desc or "xlsx" in desc or "pptx" in desc
def test_description_no_longer_says_cannot_read(self):
tool = ReadFileTool()
assert "cannot read" not in tool.description.lower()
+1 -3
View File
@@ -702,13 +702,11 @@ async def test_grep_uses_a_larger_bounded_limit_for_an_explicit_file(
assert "skipped 1 large files" in capped_result
def test_grep_schema_is_concise_and_keeps_legacy_aliases_hidden(tmp_path: Path) -> None:
def test_grep_schema_is_concise_and_hides_internal_limits(tmp_path: Path) -> None:
tool = GrepTool(workspace=tmp_path, allowed_dir=tmp_path)
properties = tool.parameters["properties"]
assert len(tool.description) < 150
assert "2 MB" not in tool.description
assert "100 MB" not in tool.description
assert "head_limit" in properties
assert "max_matches" not in properties
assert "max_results" not in properties
-30
View File
@@ -1,4 +1,3 @@
import json
from unittest.mock import MagicMock
import pytest
@@ -28,35 +27,6 @@ def test_workspace_state_defaults_when_file_missing(tmp_path, monkeypatch) -> No
assert webui_workspace_state_path() == tmp_path / "webui" / "workspace-state.json"
def test_workspace_state_ignores_legacy_project_history(tmp_path, monkeypatch) -> None:
monkeypatch.setattr("nanobot.webui.workspaces.get_webui_dir", lambda: tmp_path / "webui")
project = tmp_path / "project"
project.mkdir()
path = webui_workspace_state_path()
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(
json.dumps(
{
"recent_projects": [
{"project_path": str(project)},
{"project_path": str(tmp_path / "missing")},
],
"last_scope": {
"project_path": str(project),
"access_mode": "full",
},
}
),
encoding="utf-8",
)
state = read_webui_workspace_state()
assert "recent_projects" not in state
assert "last_scope" not in state
assert state["default_access_mode"] == "default"
def test_workspace_payload_is_config_data_dir_scoped(tmp_path, monkeypatch) -> None:
monkeypatch.setattr("nanobot.webui.workspaces.get_webui_dir", lambda: tmp_path / "webui")
default = tmp_path / "default"