Skip to content

[Test Improver] tests(install): add unit tests for integration template module#1287

Closed
danielmeppiel wants to merge 1 commit into
mainfrom
test-assist/install-template-tests-fa36c656aab9daa9
Closed

[Test Improver] tests(install): add unit tests for integration template module#1287
danielmeppiel wants to merge 1 commit into
mainfrom
test-assist/install-template-tests-fa36c656aab9daa9

Conversation

@danielmeppiel
Copy link
Copy Markdown
Collaborator

🤖 Test Improver - automated AI assistant for test improvements.

Goal and Rationale

src/apm_cli/install/template.py is a central integration hub - every dependency source (local, cached, fresh download) funnels through run_integration_template after acquisition. Despite being a critical path, it had no dedicated unit tests.

The module orchestrates three key gates:

  1. Pre-deploy security scan
  2. Primitive integration (integrate_package_primitives)
  3. Per-package verbose diagnostics

Regressions in this flow (wrong skip conditions, silent exception swallowing, wrong diagnostic keys) could cause installs to silently skip primitives or mis-report errors.

Approach

New file tests/unit/install/test_integration_template.py with 13 unit tests across 6 test classes. Uses unittest.mock.patch and MagicMock to isolate each branch cleanly.

Key branches covered:

  • acquire() returning None -> run_integration_template returns None and never calls integration
  • package_info=None or empty targets -> no-op: empty deployed list recorded, deltas returned unchanged
  • Security scan returning False -> integration skipped
  • Happy path: delta counters updated from integrate_package_primitives result; deployed files recorded
  • skill_subset routing: ctx.skill_subset when skill_subset_from_cli=True, else dep_ref.skill_subset
  • Exception in integrate_package_primitives -> error recorded in diagnostics; deltas still returned
  • Local dep exception key: dep_ref.local_path used instead of dep_key when is_local=True
  • Verbose mode: skip count and error count logged with correct plural/singular forms

Coverage Impact

Before After
install/template.py: 0 dedicated tests 13 new tests covering all main branches

Trade-offs

  • Pure mock-based tests; fast (~0.3s for all 13)
  • No filesystem I/O or real package installs
  • Does not test integrate_package_primitives internals (already covered elsewhere)

Reproducibility

# Run just these tests
.venv/bin/pytest tests/unit/install/test_integration_template.py -v

# Full unit suite
.venv/bin/pytest tests/unit/ -q

Test Status

  • New tests: 13 passing, 0 failing
  • Lint: clean (ruff check + ruff format --check both silent)
  • Pre-existing failures: 7 test_policy_status.py ANSI tests (unrelated, unchanged)

Note

🔒 Integrity filter blocked 19 items

The following items were blocked because they don't meet the GitHub integrity level.

  • #1281 list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #1277 list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #1262 list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #1248 list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #1246 list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #1245 list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #1234 list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #1227 list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #1224 list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #1146 list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #1117 list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #1113 list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #1028 list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #1017 list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #928 list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #900 list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • ... and 3 more items

To allow these resources, lower min-integrity in your GitHub frontmatter:

tools:
  github:
    min-integrity: approved  # merged | approved | unapproved | none

Generated by Daily Test Improver · ● 5.9M ·

To install this agentic workflow, run

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

Cover run_integration_template and _integrate_materialization:
- acquire() returning None (no-op)
- package_info=None / empty targets (no-op integration)
- security scan rejecting a package
- successful integration flow with delta accumulation
- skill_subset routing (from CLI vs from dep_ref)
- exception handling: error recorded in diagnostics
- local dep path used as diagnostic key for is_local deps
- verbose diagnostics: skip/error count singular and plural forms

All 13 tests pass; lint clean.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@danielmeppiel danielmeppiel added automation Deprecated: use type/automation. Kept for issue history; will be removed in milestone 0.10.0. testing Deprecated: use area/testing. Kept for issue history; will be removed in milestone 0.10.0. labels May 12, 2026
This was referenced May 22, 2026
@danielmeppiel danielmeppiel mentioned this pull request May 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automation Deprecated: use type/automation. Kept for issue history; will be removed in milestone 0.10.0. testing Deprecated: use area/testing. Kept for issue history; will be removed in milestone 0.10.0.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant