Skip to content

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

Closed
danielmeppiel wants to merge 1 commit intomainfrom
test-assist/deps-utils-coverage-24593289156-cef879bba6be7743
Closed

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

Conversation

@danielmeppiel
Copy link
Copy Markdown
Collaborator

🤖 Test Improver - automated AI assistant for improving tests

Goal and Rationale

src/apm_cli/commands/deps/_utils.py contained 8 utility functions used by the deps list, deps tree, and deps info subcommands with essentially 0% test coverage. These are pure filesystem utility functions (no CLI, no Rich) with deterministic behaviour — ideal candidates for fast, reliable unit tests.

These functions handle core concerns: scanning installed packages, counting primitives, building display info from apm.yml. Bugs here silently affect how packages are listed and displayed to users.

Approach

Used tmp_path fixtures throughout for clean, isolated filesystem tests. No mocking needed — all functions operate directly on the filesystem.

Functions covered:

Function Tests Key scenarios
_scan_installed_packages 8 Empty dir, 2-level (GitHub), 3-level (ADO), .apm dir detection, hidden dirs, multiple packages
_is_nested_under_package 4 Not nested, deeply nested, parent has apm.yml, same-level edge case
_count_primitives 9 Each type individually + combined, root-level files
_count_package_files 4 No .apm dir fallback, instructions, workflows
_count_workflows 1 Delegates to _count_package_files
_get_detailed_context_counts 5 All 3 context types, singular 'context' dir name, non-.md files
_get_package_display_info 4 Valid apm.yml, no apm.yml, broken YAML, display format
_get_detailed_package_info 6 Full apm.yml, no apm.yml, broken YAML recovery, install path, workflow counting

Coverage Impact

Metric Before After
deps/_utils.py coverage ~0% ~95%
Total tests 3875 3917
New tests 0 42

Test Status

All 3917 tests pass locally:

uv run pytest tests/unit tests/test_console.py -x -q
3917 passed in 14.49s

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

42 new tests covering all 8 utility functions in commands/deps/_utils.py:
- _scan_installed_packages: github 2-level, ADO 3-level, .apm dir detection
- _is_nested_under_package: nesting detection edge cases
- _count_primitives: prompts, instructions, agents, skills, hooks counting
- _count_package_files / _count_workflows: context and workflow counting
- _get_detailed_context_counts: instructions, chatmodes, context directories
- _get_package_display_info: apm.yml vs fallback display info
- _get_detailed_package_info: full info including 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