690b903f85
* chore: add pytest-asyncio in auto mode * test: migrate channel and stream tests to native async Convert run_async() wrapper tests to plain 'async def test_*' under pytest-asyncio auto mode. collect_events() in stream_v3_fakes becomes a coroutine awaited at every call site. * test: migrate command and model/middleware tests to native async Convert run_async() wrappers (import, alias, and fixture forms) to plain 'async def test_*'. Multi-call tests merge onto one loop as sequential awaits; none asserted on loop identity. * test: migrate TUI, notifier, gateway, and session tests to native async TUI/notifier/gateway files convert run_async wrappers to plain async tests. test_sessions.py's unittest.TestCase classes move to unittest.IsolatedAsyncioTestCase (pytest-asyncio does not await async methods on plain TestCase; converting blindly would have made ~70 tests silently vacuous). Its setUpClass keeps a one-shot asyncio.run() since IsolatedAsyncioTestCase has no async class-level hook. TestLoadingWidget in test_tui_widgets.py drops its TestCase base for the same reason. * test: replace direct asyncio.run() calls with native async tests Convert tests that called asyncio.run() (directly or via a local _run helper) to plain 'async def test_*'; delete the local helpers. * test: drop undeclared anyio markers and delete run_async helper The @pytest.mark.anyio tests relied on anyio being a transitive dep of httpx; auto-mode pytest-asyncio collects them natively. run_async() and its fixture are unreferenced after the migration, so remove them — pytest-asyncio's per-test loop teardown covers the pending-task cancellation the helper existed for (verified: full suite runs with no 'Event loop is closed' errors or destroyed-task warnings).
73 lines
2.5 KiB
Python
73 lines
2.5 KiB
Python
"""Tests for /install-skill and /uninstall-skill commands."""
|
|
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
|
|
def _ctx():
|
|
from EvoScientist.commands.base import CommandContext
|
|
|
|
ui = MagicMock()
|
|
ui.supports_interactive = True
|
|
return CommandContext(agent=None, thread_id="tid", ui=ui), ui
|
|
|
|
|
|
class TestInstallSkill:
|
|
async def test_usage_message_when_no_args(self):
|
|
from EvoScientist.commands.implementation.skills import InstallSkill
|
|
|
|
ctx, ui = _ctx()
|
|
await InstallSkill().execute(ctx, [])
|
|
msgs = [c.args[0] for c in ui.append_system.call_args_list]
|
|
assert any("Usage:" in m for m in msgs)
|
|
|
|
async def test_happy_path(self):
|
|
from EvoScientist.commands.implementation.skills import InstallSkill
|
|
|
|
ctx, ui = _ctx()
|
|
with patch(
|
|
"EvoScientist.tools.skills_manager.install_skill",
|
|
return_value={
|
|
"success": True,
|
|
"name": "demo-skill",
|
|
"description": "demo",
|
|
"path": "/tmp/demo",
|
|
},
|
|
):
|
|
await InstallSkill().execute(ctx, ["./some-path"])
|
|
msgs = [c.args[0] for c in ui.append_system.call_args_list]
|
|
assert any("Installed: demo-skill" in m for m in msgs)
|
|
|
|
|
|
class TestUninstallSkill:
|
|
async def test_usage_message_when_no_args(self):
|
|
from EvoScientist.commands.implementation.skills import UninstallSkill
|
|
|
|
ctx, ui = _ctx()
|
|
await UninstallSkill().execute(ctx, [])
|
|
msgs = [c.args[0] for c in ui.append_system.call_args_list]
|
|
assert any("Usage:" in m for m in msgs)
|
|
|
|
async def test_uninstall_success(self):
|
|
from EvoScientist.commands.implementation.skills import UninstallSkill
|
|
|
|
ctx, ui = _ctx()
|
|
with patch(
|
|
"EvoScientist.tools.skills_manager.uninstall_skill",
|
|
return_value={"success": True},
|
|
):
|
|
await UninstallSkill().execute(ctx, ["demo-skill"])
|
|
msgs = [c.args[0] for c in ui.append_system.call_args_list]
|
|
assert any("Uninstalled: demo-skill" in m for m in msgs)
|
|
|
|
async def test_uninstall_failure(self):
|
|
from EvoScientist.commands.implementation.skills import UninstallSkill
|
|
|
|
ctx, ui = _ctx()
|
|
with patch(
|
|
"EvoScientist.tools.skills_manager.uninstall_skill",
|
|
return_value={"success": False, "error": "not found"},
|
|
):
|
|
await UninstallSkill().execute(ctx, ["missing"])
|
|
msgs = [c.args[0] for c in ui.append_system.call_args_list]
|
|
assert any("Failed: not found" in m for m in msgs)
|