[Test Improver] test: add unit tests for deps/_utils.py helpers (~50% -> ~95%)#686
Draft
danielmeppiel wants to merge 1 commit intomainfrom
Draft
Conversation
Add 48 unit tests covering all 8 helper functions in src/apm_cli/commands/deps/_utils.py: - _scan_installed_packages: directory traversal for GitHub/ADO layouts - _is_nested_under_package: sub-package detection - _count_primitives: counts prompts, instructions, agents, skills, hooks - _count_package_files: context and workflow file counting - _count_workflows: wrapper around _count_package_files - _get_detailed_context_counts: per-type breakdown of context files - _get_package_display_info: display string from apm.yml - _get_detailed_package_info: full info dict including error handling Tests use tmp_path fixtures for filesystem isolation. Includes edge cases: missing directories, empty dirs, hidden dirs, exception handling, and directory naming quirks (context vs contexts). 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 focused on improving tests for this repository.
Goal and Rationale
src/apm_cli/commands/deps/_utils.pycontains 8 pure utility functions used across thedepscommand group (list, tree, info, update). These functions scan the filesystem for installed packages, count primitives, and build display/info dicts. Despite being used widely, they had no dedicated unit tests (~50% coverage from integration-level tests in other files).Adding direct unit tests here:
_scan_installed_packagesdoes NOT recursively skip children of hidden directories, only the hidden directory itself;APMPackage.sourceis not populated fromapm.yml)Approach
pytest.tmp_pathfor filesystem isolation — no mocking of IOTestXxxclass; tests cover happy path, empty inputs, edge cases, and error handlingunittest.mock.patchused only for exception-path tests (verifying graceful fallback)Coverage Impact
src/apm_cli/commands/deps/_utils.pyTest suite: 3823 → 3871 passing (+48)
Trade-offs
tmp_path); fast and hermetic, no network/subprocessReproducibility
pip install uv --break-system-packages python3 -m uv sync --extra dev python3 -m uv run pytest tests/unit/test_deps_utils.py -v # Full unit suite: python3 -m uv run pytest tests/unit tests/test_console.py -x -qTest Status
All 3871 unit tests pass locally on this branch.