Skip to content

[Test Improver] test: expand unit tests for list command (42% -> 100%)#444

Draft
danielmeppiel wants to merge 2 commits intomainfrom
test-assist/list-cmd-coverage-23519877749-2817668d6a8edeee
Draft

[Test Improver] test: expand unit tests for list command (42% -> 100%)#444
danielmeppiel wants to merge 2 commits intomainfrom
test-assist/list-cmd-coverage-23519877749-2817668d6a8edeee

Conversation

@danielmeppiel
Copy link
Copy Markdown
Collaborator

🤖 Test Improver - automated AI assistant

Goal and Rationale

list_cmd.py is user-facing (shows available scripts to developers) but was only 42% covered. The untested paths included the "no scripts found" case, the Rich table rendering branch, and exception handling. These are all exercised regularly by users.

Approach

Extended the existing tests/unit/test_list_command.py (which had 1 test) with 12 additional tests covering:

  • No scripts: warning shown, rich panel attempted → fallback on ImportError / NameError
  • Scripts found + console available: Rich table rendered, start annotated as default
  • Scripts found + no console: plain-text fallback with all script names
  • Rich table raises: fallback to plain text
  • No start script: no "default script" annotation
  • Exception in _list_available_scripts: sys.exit(1) and error message shown

Coverage Impact

File Before After
src/apm_cli/commands/list_cmd.py 42% (23/55 lines) 100% (55/55)

Test Status

All 3041 unit tests pass:

uv run pytest tests/unit/ tests/test_console.py --no-header -q
3041 passed in 13.36s

Reproducibility

# Run just the new tests
uv run pytest tests/unit/test_list_command.py -v

# Coverage
uv run pytest tests/unit/test_list_command.py --cov=apm_cli.commands.list_cmd --cov-report=term-missing

Generated by Daily Test Improver ·

To install this agentic workflow, run

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

Add 12 new tests covering list_cmd.py paths previously untested:
- No scripts found: warning shown with rich panel + fallback (ImportError/NameError)
- Scripts found: rich table rendered with default 'start' annotation
- Scripts found: fallback text when no console or rich raises
- Multiple scripts all shown in fallback
- Exception handling: sys.exit(1) with error message

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