test: improve deterministic unit test coverage
This commit is contained in:
@@ -134,7 +134,15 @@ async def test_model_command_registered_as_exact_and_prefix(tmp_path) -> None:
|
||||
out = await router.dispatch(_ctx(loop, "/model fast"))
|
||||
|
||||
assert out is not None
|
||||
assert "Switched model preset" in out.content
|
||||
assert out.channel == "cli"
|
||||
assert out.chat_id == "direct"
|
||||
assert out.metadata == {"render_as": "text"}
|
||||
assert out.content == "\n".join([
|
||||
"Switched model preset to `fast`.",
|
||||
"- Model: `openai/gpt-4.1`",
|
||||
"- Context window: 32768",
|
||||
"- Max output tokens: 4096",
|
||||
])
|
||||
assert loop.model_preset == "fast"
|
||||
|
||||
|
||||
@@ -150,7 +158,10 @@ async def test_goal_command_shows_usage_without_args(tmp_path) -> None:
|
||||
loop = _make_loop(tmp_path)
|
||||
out = await cmd_goal(_ctx(loop, "/goal"))
|
||||
assert out is not None
|
||||
assert "Usage: /goal" in out.content
|
||||
assert out.channel == "cli"
|
||||
assert out.chat_id == "direct"
|
||||
assert out.metadata == {"render_as": "text"}
|
||||
assert out.content == "Usage: /goal <long-running task description>"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -158,7 +169,13 @@ async def test_goal_command_rejects_mid_turn_without_session(tmp_path) -> None:
|
||||
loop = _make_loop(tmp_path)
|
||||
out = await cmd_goal(_ctx(loop, "/goal do work", args="do work"))
|
||||
assert out is not None
|
||||
assert "/stop" in out.content
|
||||
assert out.channel == "cli"
|
||||
assert out.chat_id == "direct"
|
||||
assert out.metadata == {"render_as": "text"}
|
||||
assert out.content == (
|
||||
"A task is already running for this chat. "
|
||||
"Use `/stop` first, then send `/goal <long-running task description>` again."
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
@@ -118,6 +118,11 @@ class TestMidTurnCommandDispatchedDirectly:
|
||||
)
|
||||
result = await router.dispatch(ctx)
|
||||
assert result is not None
|
||||
assert result.channel == "test"
|
||||
assert result.chat_id == "chat1"
|
||||
assert result.metadata["render_as"] == "text"
|
||||
assert "/new" in result.content
|
||||
assert "/pairing [list|approve <code>|deny <code>|revoke <user_id>]" in result.content
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_prefix_command_args_populated(self, router: CommandRouter) -> None:
|
||||
@@ -211,6 +216,10 @@ class TestPairingCommandDispatch:
|
||||
result = await router.dispatch(ctx)
|
||||
assert result is not None
|
||||
assert "Approved" in result.content
|
||||
assert result.content == (
|
||||
"Approved pairing code `ABCD-EFGH` — 123 can now access telegram"
|
||||
)
|
||||
assert result.metadata.get("_pairing_command") is True
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_pairing_revoke_dispatched(
|
||||
@@ -229,3 +238,5 @@ class TestPairingCommandDispatch:
|
||||
result = await router.dispatch(ctx)
|
||||
assert result is not None
|
||||
assert "Revoked" in result.content
|
||||
assert result.content == "Revoked 123 from telegram"
|
||||
assert result.metadata.get("_pairing_command") is True
|
||||
|
||||
Reference in New Issue
Block a user