Skip to content

[Test Improver] test: add error-handling and display-variation tests for view command#1100

Draft
danielmeppiel wants to merge 1 commit intomainfrom
test-assist/view-error-handling-tests-a74a186f9f129414
Draft

[Test Improver] test: add error-handling and display-variation tests for view command#1100
danielmeppiel wants to merge 1 commit intomainfrom
test-assist/view-error-handling-tests-a74a186f9f129414

Conversation

@danielmeppiel
Copy link
Copy Markdown
Collaborator

🤖 Test Improver - automated AI assistant

Goal

Cover 7 previously untested code paths in src/apm_cli/commands/view.py that handle error conditions and display variations in _display_marketplace_plugin and display_package_info.

Approach

Added tests to tests/unit/test_view_command.py in two new test classes:

TestDisplayMarketplacePluginErrors (6 tests):

  • test_marketplace_not_found_exits_1 - get_marketplace_by_name raises ValueError -> exit 1
  • test_marketplace_fetch_error_exits_1 - fetch_or_cache raises MarketplaceFetchError -> exit 1
  • test_plugin_not_found_exits_1 - plugin absent from manifest -> exit 1
  • test_plugin_with_str_source_displays - source is a plain string, renders correctly
  • test_plugin_with_tags_displays - plugin tags list appears in output
  • test_plugin_without_version_or_description - minimal plugin renders without optional fields

TestDisplayPackageInfoErrors (1 test):

  • test_package_info_read_failure_exits_1 - _get_detailed_package_info raises OSError -> exit 1 + error message shown

Coverage Impact

Metric Before After
Tests in file 34 41
New tests - +7

These are error-handling and conditional-display paths that previously had zero test coverage. The error paths are particularly valuable because they verify that bad marketplace configs fail fast with clear messages instead of crashing silently.

Trade-offs

  • All tests are fully mocked - no network calls or filesystem side-effects beyond existing patterns in the file.
  • Tests follow the same helper pattern (_force_rich_fallback, _chdir_tmp) already used in the file.

Test Status

41 passed in 1.70s

Lint: ruff check and ruff format --check both pass clean.

Reproducibility

.venv/bin/pytest tests/unit/test_view_command.py -v

Note

🔒 Integrity filter blocked 17 items

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

  • #1097 list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #1088 list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #1085 list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #1069 list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #1066 list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #1046 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".
  • #940 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".
  • #881 list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #869 list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #691 list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #655 list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #630 list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • ... and 1 more item

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 · ● 4.1M ·

To install this agentic workflow, run

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

Add 7 new tests for previously uncovered paths in view.py:
- _display_marketplace_plugin: marketplace not found (ValueError),
  MarketplaceFetchError, plugin not found
- _display_marketplace_plugin: str source, plugin with tags,
  plugin without version/description
- display_package_info: unexpected OSError exits with code 1

Tests: 41 passed (was 34)

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 2, 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