[Test Improver] test: add unit tests for mcp command (0% -> ~85%)#480
Draft
danielmeppiel wants to merge 1 commit intomainfrom
Draft
[Test Improver] test: add unit tests for mcp command (0% -> ~85%)#480danielmeppiel wants to merge 1 commit intomainfrom
danielmeppiel wants to merge 1 commit intomainfrom
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 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.pywith 25 tests covering:mcp search- Rich path with resultsmcp search- fallback (no Rich) + error handlingmcp show- Rich path (success, not found, edge cases)mcp show- fallback + error handlingmcp list- Rich path + fallback + error handlingmcp --help/ groupAll tests mock
RegistryIntegrationto avoid live network calls. TheRegistryIntegrationandrich.table.Tableare imported lazily inside function bodies, so they are patched at their canonical module locations (apm_cli.registry.integration.RegistryIntegrationandrich.table.Table).Coverage Impact
commands/mcp.pyTest Status
All 3133 unit tests pass:
Reproducibility
Trade-offs
RegistryIntegration's API contract — those are covered by the existing integration tests.rich.table.Tableis patched at the library level so table rendering itself isn't verified, but the control flow and command outcomes are.