Skip to content

[Test Improver] test: add unit tests for BaseIntegrator utility methods#577

Draft
danielmeppiel wants to merge 1 commit intomainfrom
test-assist/base-integrator-utils-23991310252-de15cf76925fbd4b
Draft

[Test Improver] test: add unit tests for BaseIntegrator utility methods#577
danielmeppiel wants to merge 1 commit intomainfrom
test-assist/base-integrator-utils-23991310252-de15cf76925fbd4b

Conversation

@danielmeppiel
Copy link
Copy Markdown
Collaborator

Summary

This PR adds direct unit tests for BaseIntegrator utility methods in src/apm_cli/integration/base_integrator.py that were previously exercised only indirectly through subclass integration tests.


🤖 Test Improver — I'm an automated AI assistant. This PR was generated as part of systematic test coverage improvement.


Goal and Rationale

BaseIntegrator is the shared infrastructure for all file-level integrators (prompts, agents, skills, hooks, instructions, commands). Its utility methods are on the critical path for install, sync, and uninstall operations across every target. While these methods had indirect coverage through the many integrator subclass tests, they lacked dedicated unit tests that:

  • Exercise each method in isolation
  • Cover edge cases not triggered by normal integrator workflows (e.g. cleanup_empty_parents with nonexistent paths, find_files_by_glob deduplication, check_collision with a diagnostics object)
  • Document expected behaviour as executable specifications

Approach

New test file: tests/unit/integration/test_base_integrator.py

Class Methods tested Tests
TestIntegrationResult dataclass defaults / custom values 2
TestCleanupEmptyParents empty list noop, bottom-up removal, stop_at boundary, sibling preservation, nonexistent paths 7
TestFindFilesByGlob pattern matching, subdir search, deduplication, missing-path safety, sorted output 7
TestNormalizeManagedFiles None passthrough, backslash normalization, mixed separators, empty set 5
TestCheckCollisionDiagnostics diagnostics.skip() vs _rich_warning routing 3
TestResolveLinks no-resolver path, unchanged-content zero count, link count, init exception, init success 5
TestShouldIntegrate always-True default 1
Total 30

Coverage Impact

No coverage tooling run (avoids PyYAML global state corruption from --cov). All 30 new tests target previously untested code paths in base_integrator.py.

Test Status

30 passed in 0.29s
3644 passed in 17.61s  (full unit suite)

All tests pass. No production code changed.

Reproducibility

# Run new tests only
uv run pytest tests/unit/integration/test_base_integrator.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 direct unit tests for BaseIntegrator methods that were
exercised only indirectly through subclass integration tests:

- cleanup_empty_parents: empty-list noop, bottom-up removal,
  stop_at boundary, sibling preservation, nonexistent path handling
- find_files_by_glob: pattern matching, subdir search,
  deduplication, missing-path safety, sorted output
- normalize_managed_files: None passthrough, backslash normalization
- check_collision (diagnostics path): diagnostics.skip() called
  instead of _rich_warning when diagnostics object provided
- resolve_links / init_link_resolver: no-resolver path, zero-count
  when content unchanged, link-count computation, exception handling

30 new tests, all passing. No production code changed.

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