Skip to content

[Test Improver] test: add unit tests for deps/_utils.py utility functions#672

Draft
danielmeppiel wants to merge 1 commit intomainfrom
test-assist/deps-utils-coverage-24271066705-17a9bf3359f644a4
Draft

[Test Improver] test: add unit tests for deps/_utils.py utility functions#672
danielmeppiel wants to merge 1 commit intomainfrom
test-assist/deps-utils-coverage-24271066705-17a9bf3359f644a4

Conversation

@danielmeppiel
Copy link
Copy Markdown
Collaborator

🤖 Test Improver here - I'm an automated AI assistant focused on improving test coverage for this repository.

Goal

apm_cli/commands/deps/_utils.py contained utility functions with minimal test coverage (~50%). These pure filesystem helpers are used by the deps list, deps tree, deps info, and view commands, making them important to validate independently.

Approach

Added 43 unit tests in tests/unit/test_deps_utils.py covering all 8 utility functions:

Function Tests Key scenarios
_scan_installed_packages 7 empty dir, nonexistent path, GitHub/ADO-style layouts, hidden dirs, multi-package
_is_nested_under_package 3 top-level, nested under parent with apm.yml
_count_primitives 10 prompts, instructions, agents, skills (SKILL.md), hooks in root/apm dir, mixed
_count_package_files / _count_workflows 6 no .apm dir, instructions as context, prompts as workflows, root-level prompts
_get_detailed_context_counts 5 no .apm dir, each type, combined; note context/ dir -> contexts key
_get_package_display_info 4 valid apm.yml, missing apm.yml, display_name format, corrupt yaml fallback
_get_detailed_package_info 8 full info, no apm.yml, hooks, absolute install_path, error recovery

One insight from writing the tests: _scan_installed_packages only skips candidate directories whose own name starts with . — it still traverses into hidden parent directories. Tests document this actual behavior.

Coverage Impact

  • Before: deps/_utils.py covered indirectly via test_deps_list_tree_info.py (partial, ~50% estimated)
  • After: All 8 functions directly tested with explicit edge-case coverage

Test Status

All 3866 tests pass (3823 baseline + 43 new):

python3 -m uv run pytest tests/unit tests/test_console.py -x -q
3866 passed in 19.67s

Reproducibility

# Run new tests only
uv run pytest tests/unit/test_deps_utils.py -v

# Full unit suite
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

Add 43 unit tests covering all functions in
apm_cli/commands/deps/_utils.py:
- _scan_installed_packages: empty dir, nonexistent, GitHub/ADO style,
  hidden package dirs, multiple packages
- _is_nested_under_package: top-level, nested inside parent package
- _count_primitives: prompts, instructions, agents, skills, hooks,
  root-level files, mixed primitives
- _count_package_files / _count_workflows: context dirs, workflow files,
  root-level prompts, combined
- _get_detailed_context_counts: instructions, chatmodes, context (singular
  dir -> 'contexts' key)
- _get_package_display_info: valid apm.yml, missing apm.yml, display_name
  format, corrupt yaml fallback
- _get_detailed_package_info: full info, no apm.yml defaults, hooks count,
  absolute install_path, error recovery

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