feat(ci): add GitHub Actions workflow for test directory

- nanobot/channels/matrix.py: Add keyword-only parameters restrict_to_workspace/workspace to MatrixChannel.__init__ and assign them to _restrict_to_workspace/_workspace with proper type conversion and path resolution
- tests/test_commands.py: Add _strip_ansi() function to remove ANSI escape codes, use regex assertions for --workspace/--config parameters to allow 1 or 2 dashes
This commit is contained in:
Jiajun Xie
2026-03-12 13:33:59 +08:00
parent 95c741db62
commit ec6e099393
3 changed files with 56 additions and 7 deletions

View File

@@ -1,3 +1,4 @@
import re
import shutil
from pathlib import Path
from unittest.mock import AsyncMock, MagicMock, patch
@@ -11,6 +12,12 @@ from nanobot.providers.litellm_provider import LiteLLMProvider
from nanobot.providers.openai_codex_provider import _strip_model_prefix
from nanobot.providers.registry import find_by_model
def _strip_ansi(text):
"""Remove ANSI escape codes from text."""
ansi_escape = re.compile(r'\x1b\[[0-9;]*m')
return ansi_escape.sub('', text)
runner = CliRunner()
@@ -199,10 +206,11 @@ def test_agent_help_shows_workspace_and_config_options():
result = runner.invoke(app, ["agent", "--help"])
assert result.exit_code == 0
assert "--workspace" in result.stdout
assert "-w" in result.stdout
assert "--config" in result.stdout
assert "-c" in result.stdout
stripped_output = _strip_ansi(result.stdout)
assert re.search(r'-{1,2}workspace', stripped_output)
assert re.search(r'-w', stripped_output)
assert re.search(r'-{1,2}config', stripped_output)
assert re.search(r'-c', stripped_output)
def test_agent_uses_default_config_when_no_workspace_or_config_flags(mock_agent_runtime):