Skip to content

[Test Improver] test: add unit tests for mcp command (0% -> ~85%)#480

Draft
danielmeppiel wants to merge 1 commit intomainfrom
test-assist/mcp-command-coverage-23673961971-7bb743c5252c0208
Draft

[Test Improver] test: add unit tests for mcp command (0% -> ~85%)#480
danielmeppiel wants to merge 1 commit intomainfrom
test-assist/mcp-command-coverage-23673961971-7bb743c5252c0208

Conversation

@danielmeppiel
Copy link
Copy Markdown
Collaborator

🤖 Test Improver here - I'm an automated AI assistant focused on improving tests for this repository.

Goal and Rationale

src/apm_cli/commands/mcp.py (379 lines) had zero dedicated unit tests. It implements three user-facing CLI commands (search, show, list) that hit the MCP registry. Each command has two execution paths: a Rich console path and a plain-text fallback path. Testing both paths guards against regressions in either rendering mode.

Approach

Added tests/unit/test_mcp_command.py with 25 tests covering:

Area Tests
mcp search - Rich path with results 4 tests
mcp search - fallback (no Rich) + error handling 4 tests
mcp show - Rich path (success, not found, edge cases) 6 tests
mcp show - fallback + error handling 3 tests
mcp list - Rich path + fallback + error handling 6 tests
mcp --help / group 1 test
Total 25 tests

All tests mock RegistryIntegration to avoid live network calls. The RegistryIntegration and rich.table.Table are imported lazily inside function bodies, so they are patched at their canonical module locations (apm_cli.registry.integration.RegistryIntegration and rich.table.Table).

Coverage Impact

File Before After (est.)
commands/mcp.py ~0% ~85%

Test Status

All 3133 unit tests pass:

python3 -m uv run pytest tests/unit tests/test_console.py -x -q
3133 passed in 15.59s

Reproducibility

# Run only new tests
uv run pytest tests/unit/test_mcp_command.py -v

# Run full unit suite
uv run pytest tests/unit tests/test_console.py -x -q

Trade-offs

  • Tests mock the registry entirely, so they don't catch changes in RegistryIntegration's API contract — those are covered by the existing integration tests.
  • rich.table.Table is patched at the library level so table rendering itself isn't verified, but the control flow and command outcomes are.

Generated by Daily Test Improver ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/daily-test-improver.md@b87234850bf9664d198f28a02df0f937d0447295

25 new tests covering both Rich console and fallback paths for all
three mcp subcommands. Addresses the commands/mcp.py coverage gap.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant