[Test Improver] test: add unit tests for mcp command group (search/show/list)#483
Draft
danielmeppiel wants to merge 1 commit intomainfrom
Draft
Conversation
22 new tests covering: - mcp search: no results, results found, network error (rich + fallback paths) - mcp show: server not found, full detail with packages/remotes, network error - mcp list: no results, results found, limit hint, verbose flag - Description truncation and package name truncation edge cases RegistryIntegration is lazily imported inside function bodies; tests patch at apm_cli.registry.integration.RegistryIntegration (the source module). 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.
Summary
Adds 22 new unit tests for
src/apm_cli/commands/mcp.py— theapm mcp search,apm mcp show, andapm mcp listcommands — which had no dedicated test file.Goal and Rationale
The
mcpcommand group is a user-facing feature for registry discovery. It had zero dedicated unit tests. These commands involve network calls (RegistryIntegration), Rich console output, and fallback plain-text paths — all of which benefit from being tested in isolation.Approach
RegistryIntegrationatapm_cli.registry.integration.RegistryIntegration(lazy import inside function bodies — not patchable atapm_cli.commands.mcp)._get_consoleto toggle between the Rich console path and the non-Rich fallback path.CliRunnervia theclientry point for realistic invocation.Coverage Impact
src/apm_cli/commands/mcp.pyTest Status
All 22 new tests pass. No regressions.
Reproducibility
Trade-offs
RegistryIntegrationmust be patched at its source module, not atmcp. This is documented as a comment in the test file to avoid future confusion.console.printcalls and asserts they are made, which is the right level of abstraction for CLI command tests.