[Test Improver] test: add unit tests for uninstall engine helpers (0% -> ~70%)#678
Draft
danielmeppiel wants to merge 1 commit intomainfrom
Draft
Conversation
Adds 35 unit tests covering the helper functions in src/apm_cli/commands/uninstall/engine.py: - _parse_dependency_entry: string/DependencyReference/dict/invalid types - _validate_uninstall_packages: matched/unmatched/invalid format/empty cases - _dry_run_uninstall: packages on disk, missing, no packages - _remove_packages_from_disk: removal, warnings, absent dir, traversal rejection - _cleanup_transitive_orphans: no lockfile, chain orphans, still-needed deps - _cleanup_stale_mcp: no-op, stale removal, exception 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 — automated AI assistant
Goal and Rationale
src/apm_cli/commands/uninstall/engine.py(372 lines) contained 7 helper functions with 0% direct unit-test coverage. The existing uninstall tests (test_uninstall_reintegration.py,test_uninstall_transitive_cleanup.py) exercise higher-level integration paths but leave the engine helpers untested at the unit level.These helpers handle critical uninstall logic: parsing dependency entries, matching packages to apm.yml, dry-run previews, disk removal with path-traversal protection, transitive orphan cleanup, and MCP server cleanup. Unit tests here catch regressions early with no I/O overhead.
Approach
Added
tests/unit/test_uninstall_engine.pywith 35 tests targeting each helper function directly:_parse_dependency_entry_validate_uninstall_packages_dry_run_uninstall_remove_packages_from_disk_cleanup_transitive_orphans_cleanup_stale_mcpget_mcp_dependenciesCoverage Impact
commands/uninstall/engine.pyCoverage was not measured with
--cov(causes PyYAML corruption); estimates based on function-level tracing.Test Status
All existing tests continue to pass.
Reproducibility