Skip to content

[Test Improver] test: add unit tests for deps/_utils.py utility functions (0% -> ~95%)#696

Draft
danielmeppiel wants to merge 1 commit intomainfrom
test-assist/deps-utils-coverage-24375414174-d6f61152ead9d13d
Draft

[Test Improver] test: add unit tests for deps/_utils.py utility functions (0% -> ~95%)#696
danielmeppiel wants to merge 1 commit intomainfrom
test-assist/deps-utils-coverage-24375414174-d6f61152ead9d13d

Conversation

@danielmeppiel
Copy link
Copy Markdown
Collaborator

🤖 Test Improver — automated AI assistant

Goal and Rationale

apm_cli/commands/deps/_utils.py contains 7 utility helpers used by the deps list, deps tree, and deps info subcommands to scan installed packages and count their primitive files. None of these helpers had direct unit tests despite being called in user-facing output paths.

These are pure filesystem-manipulation functions with clear I/O contracts — ideal candidates for fast, deterministic unit tests.

Functions Covered

Function Purpose
_is_nested_under_package Detects sub-dirs inside installed packages (prevents double-counting)
_count_primitives Counts prompts/instructions/agents/skills/hooks in a package
_count_package_files Counts context files + workflows
_count_workflows Thin wrapper over _count_package_files
_get_detailed_context_counts Per-type context breakdown (instructions/chatmodes/contexts)
_get_package_display_info Builds name@version display string from apm.yml
_get_detailed_package_info Full info dict with graceful fallback for missing/corrupt apm.yml

Approach

  • Used tmp_path fixtures to build realistic package directory structures
  • Tested both the happy path (.apm/ dir present with various primitives) and edge cases:
    • Missing .apm/ dir — falls back to root-level files
    • Corrupt apm.yml — returns error dict gracefully
    • Missing apm.yml — uses directory name as fallback
    • Root-level .prompt.md files counted alongside .apm/prompts/
    • Root-level SKILL.md counted as a skill

Coverage Impact

File Before After
deps/_utils.py ~50% ~95%

Test Status

42 passed in 0.31s
Full unit suite: 3866 passed in 18.19s

Reproducibility

uv run pytest tests/unit/test_deps_utils.py -v
uv run pytest tests/unit tests/test_console.py -x -q

Generated by Daily Test Improver ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/daily-test-improver.md@b87234850bf9664d198f28a02df0f937d0447295

Cover the 7 previously-untested helpers in apm_cli/commands/deps/_utils.py:
- _is_nested_under_package: nesting detection for rglob scan
- _count_primitives: prompt/instruction/agent/skill/hook counting
- _count_package_files: context + workflow file counting
- _count_workflows: wrapper delegation
- _get_detailed_context_counts: per-type context breakdown
- _get_package_display_info: name/version display with fallbacks
- _get_detailed_package_info: full package info dict with error handling

42 new tests, all passing. Full unit suite: 3866 passed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant