79b0a2c52e
CI / lint (push) Successful in 26s
CI / typecheck (push) Successful in 43s
CI / quality (push) Successful in 34s
CI / security (push) Successful in 1m20s
CI / build (push) Successful in 17s
CI / unit_tests (push) Successful in 4m12s
CI / benchmark-regression (push) Has been skipped
CI / integration_tests (push) Successful in 4m9s
CI / docker (push) Successful in 1m23s
CI / e2e_tests (push) Successful in 5m48s
CI / coverage (push) Failing after 13m57s
CI / benchmark-publish (push) Successful in 23m24s
## Summary Migrates 8 CLI command modules from module-level `Console()` objects to the shared `_get_console()` from `renderers.py`. This eliminates redundant Console instances and ensures consistent output handling across all CLI commands. ### Modules Migrated | Module | Change | |--------|--------| | `auto_debug.py` | `Console()` → `_get_console()` | | `context.py` | `Console()` → `_get_console()` | | `automation_profile.py` | `Console()` → `_get_console()` | | `tool.py` | `Console()` → `_get_console()` | | `project.py` | Both stdout + stderr Console → shared instances | | `config.py` | `Console()` → `_get_console()` | | `resource.py` | `Console()` → `_get_console()` | | `skill.py` | `Console()` → `_get_console()` | ### Approach Each module-level `console = Console()` was replaced with `console = _get_console()`, keeping the module attribute name `console` intact for backward compatibility with existing test patches. The `from rich.console import Console` import was removed from each module. Modules NOT migrated in this PR (documented for follow-up): - `plan.py` — uses streaming/Live display, too large for this scope - `session.py`, `repl.py`, `lsp.py`, `server.py` — specialized usage patterns ### Quality Gates | Session | Result | |---------|--------| | `nox -s lint` | PASS | | `nox -s typecheck` | PASS (0 errors) | | Unit tests (targeted) | All affected scenarios pass | Partial implementation of #813 (step 2 of 4: Console consolidation). Steps 1, 3, 4 remain open on issue #813. Reviewed-on: #1059 Co-authored-by: Brent E. Edwards <brent.edwards@cleverthis.com> Co-committed-by: Brent E. Edwards <brent.edwards@cleverthis.com>
99 lines
4.4 KiB
Gherkin
99 lines
4.4 KiB
Gherkin
@mock_only
|
|
Feature: CLI renderers coverage
|
|
Verifies render_error, render_success, render_warning, and render_empty
|
|
helper functions across all output formats (rich, json, plain).
|
|
|
|
# --- render_error ---
|
|
|
|
Scenario: render_error with rich format shows red label
|
|
Given a captured console for renderers
|
|
When I call render_error with label "NOT_FOUND" message "Item missing" fmt "rich"
|
|
Then the renderer output should contain "NOT_FOUND"
|
|
And the renderer output should contain "Item missing"
|
|
|
|
Scenario: render_error with json format produces JSON envelope
|
|
Given a captured console for renderers
|
|
When I call render_error with label "NOT_FOUND" message "Item missing" fmt "json"
|
|
Then the renderer output should contain "NOT_FOUND"
|
|
|
|
Scenario: render_error with plain format shows ERROR prefix
|
|
Given a captured console for renderers
|
|
When I call render_error with label "NOT_FOUND" message "Item missing" fmt "plain"
|
|
Then the renderer output should contain "ERROR: NOT_FOUND: Item missing"
|
|
|
|
Scenario: render_error with recovery hint in rich format
|
|
Given a captured console for renderers
|
|
And a recovery hint "Try 'list' first"
|
|
When I call render_error with label "NOT_FOUND" message "Item missing" fmt "rich"
|
|
Then the renderer output should contain "Try 'list' first"
|
|
|
|
Scenario: render_error with recovery hint in plain format
|
|
Given a captured console for renderers
|
|
And a recovery hint "Try 'list' first"
|
|
When I call render_error with label "NOT_FOUND" message "Item missing" fmt "plain"
|
|
Then the renderer output should contain "Try 'list' first"
|
|
|
|
# --- render_success ---
|
|
|
|
Scenario: render_success with rich format shows green check
|
|
Given a captured console for renderers
|
|
When I call render_success with message "Created project" fmt "rich"
|
|
Then the renderer output should contain "Created project"
|
|
|
|
Scenario: render_success with json format produces JSON
|
|
Given a captured console for renderers
|
|
When I call render_success with message "Created project" fmt "json"
|
|
Then the renderer output should contain "ok"
|
|
|
|
Scenario: render_success with plain format shows OK prefix
|
|
Given a captured console for renderers
|
|
When I call render_success with message "Created project" fmt "plain"
|
|
Then the renderer output should contain "OK: Created project"
|
|
|
|
# --- render_warning ---
|
|
|
|
Scenario: render_warning with rich format shows yellow text
|
|
Given a captured console for renderers
|
|
When I call render_warning with message "Deprecated feature" fmt "rich"
|
|
Then the renderer output should contain "Deprecated feature"
|
|
|
|
Scenario: render_warning with json format produces JSON
|
|
Given a captured console for renderers
|
|
When I call render_warning with message "Deprecated feature" fmt "json"
|
|
Then the renderer output should contain "warning"
|
|
|
|
Scenario: render_warning with plain format shows WARNING prefix
|
|
Given a captured console for renderers
|
|
When I call render_warning with message "Deprecated feature" fmt "plain"
|
|
Then the renderer output should contain "WARNING: Deprecated feature"
|
|
|
|
# --- render_empty ---
|
|
|
|
Scenario: render_empty with rich format shows yellow message
|
|
Given a captured console for renderers
|
|
When I call render_empty with entity_type "actions" fmt "rich"
|
|
Then the renderer output should contain "No actions found"
|
|
|
|
Scenario: render_empty with json format produces empty list
|
|
Given a captured console for renderers
|
|
When I call render_empty with entity_type "actions" fmt "json"
|
|
Then the renderer output should contain "[]"
|
|
|
|
Scenario: render_empty with plain format shows text
|
|
Given a captured console for renderers
|
|
When I call render_empty with entity_type "actions" fmt "plain"
|
|
Then the renderer output should contain "No actions found."
|
|
|
|
Scenario: render_empty with recovery hint in rich format
|
|
Given a captured console for renderers
|
|
And a recovery hint "Run 'action create' first"
|
|
When I call render_empty with entity_type "actions" fmt "rich"
|
|
Then the renderer output should contain "Run 'action create' first"
|
|
|
|
Scenario: render_empty with table format and recovery
|
|
Given a captured console for renderers
|
|
And a recovery hint "Run 'project create' first"
|
|
When I call render_empty with entity_type "projects" fmt "table"
|
|
Then the renderer output should contain "No projects found."
|
|
And the renderer output should contain "Run 'project create' first"
|