[Test Improver] test: add unit tests for uninstall CLI command (22 tests)#557
Draft
danielmeppiel wants to merge 1 commit intomainfrom
Draft
Conversation
Tests cover the apm uninstall CLI command end-to-end: - Missing apm.yml (project and user scope) - Package not found in apm.yml (graceful warning) - Dry-run: shows what would be removed, no side-effects - Successful uninstall: removes from apm.yml + apm_modules/ - Multiple packages in one invocation - Lockfile update after partial removal - Lockfile deletion when last package removed - --global / user scope flag - --verbose flag - Integration cleanup counts in output - YAML read/write error handling 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 - automated AI assistant for test improvements.
Goal and Rationale
The
apm uninstallCLI command (src/apm_cli/commands/uninstall/cli.py, 213 lines) orchestrates the entire uninstall flow — checking apm.yml exists, reading/writing YAML, removing packages from disk, updating the lockfile, syncing integrations, and MCP cleanup. Despite two existing engine-level test files (test_uninstall_reintegration.py,test_uninstall_transitive_cleanup.py), the CLI command itself had zero direct test coverage. This PR fills that gap.Approach
22 end-to-end tests exercising the Click CLI command via
CliRunner, following the same pattern astest_prune_command.py. Tests use a real temp directory (chdir pattern) for the project-scope path, and mock only the heavy integration/MCP sync callbacks.Test cases:
apm.yml→ exit 1 (project and user scope)apm.yml→ warning + exit 0--dry-run: shows what would be removed, leaves files untouchedapm.yml+apm_modules/--global/ user scope flag (missing manifest and successful removal)--verboseflag acceptedCoverage Impact
uninstall/cli.pyCLI commandNote: No
--covflag used (known PyYAML global-state corruption with coverage plugin).Reproducibility