test: remove unreachable cases and strengthen weak assertions
This commit is contained in:
1 parent
169062be11
commit
abfe510ce1
25 files changed
+64
-302
No files matched your search
@@ -340,26 +340,6 @@ class TestCheckExpired:
|
||||
await ac.check_expired(scheduler, _resolve_runtime)
|
||||
scheduler.assert_not_called()
|
||||
|
||||
async def test_session_with_no_key_skips(self):
|
||||
"""Session info with empty/missing key should be skipped."""
|
||||
ac = _make_autocompact(ttl=15)
|
||||
mock_sm = _mock_sessions()
|
||||
mock_sm.list_sessions.return_value = [{"key": "", "updated_at": "old"}]
|
||||
ac.sessions = mock_sm
|
||||
scheduler = MagicMock()
|
||||
await ac.check_expired(scheduler, _resolve_runtime)
|
||||
scheduler.assert_not_called()
|
||||
|
||||
async def test_session_with_missing_key_field_skips(self):
|
||||
"""Session info dict without 'key' field should be skipped."""
|
||||
ac = _make_autocompact(ttl=15)
|
||||
mock_sm = _mock_sessions()
|
||||
mock_sm.list_sessions.return_value = [{"updated_at": "old"}]
|
||||
ac.sessions = mock_sm
|
||||
scheduler = MagicMock()
|
||||
await ac.check_expired(scheduler, _resolve_runtime)
|
||||
scheduler.assert_not_called()
|
||||
|
||||
async def test_dream_session_skips(self):
|
||||
"""Internal Dream sessions should not be scheduled for idle compact."""
|
||||
ac = _make_autocompact(ttl=15)
|
||||
|
||||
@@ -313,16 +313,6 @@ class TestFormatValue:
|
||||
class TestSyncWorkspaceTemplates:
|
||||
"""Tests for sync_workspace_templates file synchronization."""
|
||||
|
||||
def test_creates_missing_files(self, tmp_path):
|
||||
"""Should create template files that don't exist."""
|
||||
workspace = tmp_path / "workspace"
|
||||
|
||||
added = sync_workspace_templates(workspace, silent=True)
|
||||
|
||||
# Check that some files were created
|
||||
assert isinstance(added, list)
|
||||
# The actual files depend on the templates directory
|
||||
|
||||
def test_does_not_overwrite_existing_files(self, tmp_path):
|
||||
"""Should not overwrite files that already exist."""
|
||||
workspace = tmp_path / "workspace"
|
||||
@@ -398,13 +388,16 @@ class TestProviderChannelInfo:
|
||||
assert "openai_codex" not in names
|
||||
assert "github_copilot" not in names
|
||||
|
||||
def test_get_channel_names_returns_dict(self):
|
||||
from nanobot.cli.onboard import _get_channel_names
|
||||
def test_get_channel_names_maps_display_names(self, monkeypatch):
|
||||
monkeypatch.setattr(onboard_wizard, "_get_channel_info", lambda: {
|
||||
"first": ("First channel", Config),
|
||||
"second": ("Second channel", Config),
|
||||
})
|
||||
|
||||
names = _get_channel_names()
|
||||
assert isinstance(names, dict)
|
||||
# Should include at least some channels
|
||||
assert len(names) >= 0
|
||||
assert onboard_wizard._get_channel_names() == {
|
||||
"first": "First channel",
|
||||
"second": "Second channel",
|
||||
}
|
||||
|
||||
def test_get_provider_info_returns_valid_structure(self):
|
||||
from nanobot.cli.onboard import _get_provider_info
|
||||
@@ -1780,26 +1773,6 @@ class TestMainMenuInteraction:
|
||||
assert loginchat["enabled"] is True
|
||||
assert calls == {"force": False}
|
||||
|
||||
def test_main_menu_dispatch_includes_channel_common(self):
|
||||
"""Advanced menu dispatch should route [H] to Channel Common."""
|
||||
|
||||
# We verify by checking the dispatch table is set up correctly
|
||||
# The menu items are defined inline in run_onboard, so we test
|
||||
# that _configure_general_settings handles the new sections.
|
||||
from nanobot.cli.onboard import _SETTINGS_GETTER, _SETTINGS_SECTIONS, _SETTINGS_SETTER
|
||||
|
||||
assert "Channel Common" in _SETTINGS_SECTIONS
|
||||
assert "Channel Common" in _SETTINGS_GETTER
|
||||
assert "Channel Common" in _SETTINGS_SETTER
|
||||
|
||||
def test_main_menu_dispatch_includes_api_server(self):
|
||||
"""Advanced menu dispatch should route [I] to API Server."""
|
||||
from nanobot.cli.onboard import _SETTINGS_GETTER, _SETTINGS_SECTIONS, _SETTINGS_SETTER
|
||||
|
||||
assert "API Server" in _SETTINGS_SECTIONS
|
||||
assert "API Server" in _SETTINGS_GETTER
|
||||
assert "API Server" in _SETTINGS_SETTER
|
||||
|
||||
def test_run_onboard_channel_common_edit(self, monkeypatch):
|
||||
"""run_onboard should handle [H] Channel Common through Advanced Settings."""
|
||||
initial_config = Config()
|
||||
@@ -2168,12 +2141,6 @@ class TestModelPresetWizard:
|
||||
assert defaults.model_preset is None
|
||||
_MODEL_PRESET_CACHE.clear()
|
||||
|
||||
def test_main_menu_dispatch_includes_model_presets(self):
|
||||
"""_configure_model_presets should be importable and callable."""
|
||||
from nanobot.cli.onboard import _configure_model_presets
|
||||
|
||||
assert callable(_configure_model_presets)
|
||||
|
||||
def test_run_onboard_model_presets_edit(self, monkeypatch):
|
||||
"""run_onboard should handle [M] Model Presets through Advanced Settings."""
|
||||
from nanobot.config.schema import ModelPresetConfig
|
||||
|
||||
@@ -612,17 +612,6 @@ class TestRunningCounts:
|
||||
|
||||
|
||||
class TestSubagentHook:
|
||||
@pytest.mark.asyncio
|
||||
async def test_before_execute_tools_without_status_preserves_calls(self):
|
||||
hook = _SubagentHook()
|
||||
tool_call = MagicMock()
|
||||
tool_call.name = "read_file"
|
||||
tool_call.arguments = {"path": "/tmp/test"}
|
||||
ctx = _make_hook_context(tool_calls=[tool_call])
|
||||
result = await hook.before_execute_tools(ctx)
|
||||
assert result is None
|
||||
assert ctx.tool_calls == [tool_call]
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_after_iteration_updates_status(self):
|
||||
status = SubagentStatus(
|
||||
@@ -639,14 +628,6 @@ class TestSubagentHook:
|
||||
assert len(status.tool_events) == 1
|
||||
assert status.usage == LLMUsage.reported(input_tokens=100, output_tokens=0)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_after_iteration_no_status_noop(self):
|
||||
hook = _SubagentHook()
|
||||
ctx = _make_hook_context(iteration=5)
|
||||
result = await hook.after_iteration(ctx)
|
||||
assert result is None
|
||||
assert ctx.iteration == 5
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_after_iteration_sets_error(self):
|
||||
status = SubagentStatus(
|
||||
|
||||
@@ -628,19 +628,6 @@ class TestSubagentHookStatus:
|
||||
|
||||
assert status.error == "something went wrong"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_after_iteration_no_status_is_noop(self):
|
||||
"""after_iteration with no status should be a no-op."""
|
||||
from nanobot.agent.hook import AgentHookContext
|
||||
from nanobot.agent.subagent import _SubagentHook
|
||||
|
||||
hook = _SubagentHook()
|
||||
context = AgentHookContext(iteration=1, messages=[])
|
||||
result = await hook.after_iteration(context)
|
||||
|
||||
assert result is None
|
||||
assert context.iteration == 1
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# read-only mode (tools.my.allow_set=False)
|
||||
|
||||
Reference in new issue
Block a user