Skip to content

[Test Improver] test: add unit tests for compile CLI display helpers#522

Draft
danielmeppiel wants to merge 1 commit intomainfrom
test-assist/compile-cli-helpers-23826960523-f599b19e900c41e6
Draft

[Test Improver] test: add unit tests for compile CLI display helpers#522
danielmeppiel wants to merge 1 commit intomainfrom
test-assist/compile-cli-helpers-23826960523-f599b19e900c41e6

Conversation

@danielmeppiel
Copy link
Copy Markdown
Collaborator

🤖 Test Improver — automated AI assistant

Goal and Rationale

The apm compile command has 578 lines of CLI logic, but only a single subprocess-level integration test (test_compile_rich_output.py, 19 lines). The four display helper functions — _get_validation_suggestion, _display_validation_errors, _display_next_steps, and _display_single_file_summary — had zero unit tests. These helpers are called on every successful or failed compilation and handle user-facing feedback including validation errors.

Approach

Unit tests for the four pure/display-layer helpers in apm_cli.commands.compile.cli:

Function What's tested
_get_validation_suggestion All 4 branches: description, applyTo, empty content, generic fallback; type safety; case sensitivity
_display_validation_errors Rich table path, no-console fallback, ImportError fallback, colon-split error parsing, empty error list, multi-error table
_display_next_steps Rich panel path, no-console fallback, ImportError fallback, custom output filename in output
_display_single_file_summary Rich table path, no-console fallback, dry-run mode, real file size computation, missing stats .get() defaults, None hash renders as -, exception fallback

Mocks patch apm_cli.commands.compile.cli._get_console (the resolved import name) so tests work without a live terminal.

Coverage Impact

Module Before After (estimated)
commands/compile/cli.py (helpers only) ~0% for display helpers ~80%+ for helper functions

Trade-offs

  • Tests cover the display and fallback paths; the main compile() Click command orchestration is out of scope (requires project fixture setup and is covered by the subprocess integration test).
  • No new dependencies added.

Reproducibility

uv run pytest tests/unit/test_compile_cli_helpers.py -v
```

## Test Status

**23/23 tests pass. 3422 total tests pass (0 regressions).**

```
tests/unit/test_compile_cli_helpers.py::TestGetValidationSuggestion::test_missing_description_branch PASSED
tests/unit/test_compile_cli_helpers.py::TestGetValidationSuggestion::test_missing_applyto_branch PASSED
tests/unit/test_compile_cli_helpers.py::TestGetValidationSuggestion::test_empty_content_branch PASSED
tests/unit/test_compile_cli_helpers.py::TestGetValidationSuggestion::test_unknown_error_returns_generic PASSED
tests/unit/test_compile_cli_helpers.py::TestGetValidationSuggestion::test_case_sensitive_matching PASSED
tests/unit/test_compile_cli_helpers.py::TestGetValidationSuggestion::test_returns_string_for_all_branches PASSED
tests/unit/test_compile_cli_helpers.py::TestDisplayValidationErrors::test_rich_path_with_colon_error PASSED
... (23 total, all PASSED)
23 passed in 0.27s

Generated by Daily Test Improver ·

To install this agentic workflow, run

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

Add 23 unit tests covering the four pure/display-layer helpers in
apm_cli.commands.compile.cli:

* _get_validation_suggestion -- all 4 branches (description, applyTo,
  empty content, generic fallback) plus type safety
* _display_validation_errors -- rich table path, fallback when no
  console, ImportError fallback, colon-split error parsing, empty list
* _display_next_steps -- rich panel path, fallback when no console,
  ImportError fallback, custom output filename
* _display_single_file_summary -- rich table path, no-console fallback,
  dry-run mode, real file size computation, missing stats defaults, None
  hash handling, exception fallback

All 23 tests pass against the 3422-test suite (0 regressions).

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