TEST-INFRA: [coverage-gaps] Add test coverage for CLI context management and error handling #3796

Open
opened 2026-04-06 06:23:11 +00:00 by freemo · 0 comments
Owner

Metadata

  • Branch: test/coverage-cli-context-management
  • Commit Message: test(cli): add Behave coverage for context management commands and error handling
  • Milestone: (none — backlog, see note below)
  • Parent Epic: #396

Background and Context

The file src/cleveragents/cli.py has a significant coverage gap at 62.01%. The existing tests primarily cover the happy path of the run command but neglect the extensive context management features and various error handling paths. The ACMS Context Pipeline Epic (#396) explicitly lists "Context assembly CLI functional (context list/add/show/clear)" as an acceptance criterion — without adequate test coverage, this criterion cannot be verified with confidence.

Current Behavior

The following key areas of src/cleveragents/cli.py are completely untested:

  • Context Management: The entire context command group, including subcommands for listing, showing, clearing, deleting, and exporting contexts.
  • Error Handling: Numerous try...except blocks handling CleverAgentsException, FileNotFoundError, and user configuration errors.
  • Alternative Execution Paths: Conditional paths based on different combinations of --load-context, --context, --context-dir, and --all flags.
  • Interactive Mode with Context: Logic for starting an interactive session with a loaded context.
  • Edge Cases: Branches handling no-contexts-found, context-already-exists, and similar boundary conditions.

Expected Behavior

src/cleveragents/cli.py should have test coverage that contributes to the project-wide ≥ 97% coverage requirement. All context management subcommands and error handling paths should be exercised by Behave scenarios.

Acceptance Criteria

  • cleveragents context list is tested for both the empty-contexts and multiple-contexts cases.
  • cleveragents context show <name> is tested for an existing context and a non-existing context.
  • cleveragents context clear <name> is tested.
  • cleveragents context delete <name> and cleveragents context delete --all are tested.
  • cleveragents context export <name> <file> is tested.
  • cleveragents run --load-context <file> --context <name> (context import path) is tested.
  • Error handling paths (invalid config path, malformed config, CleverAgentsException propagation) are tested.
  • Alternative execution paths for --load-context, --context, and --context-dir combinations are tested.
  • Interactive mode with --load-context is tested.
  • All new mocks and test doubles are placed exclusively in features/mocks/.
  • Overall project coverage remains ≥ 97% (nox -e coverage_report).
  • All nox sessions pass with zero errors.

Supporting Information

  • File with missing coverage: src/cleveragents/cli.py
  • Current coverage: 62.01%
  • Analysis tool: ca-test-infra-improver (worker mode)
  • Parent Epic: #396 — Epic: ACMS Context Pipeline (acceptance criterion: "Context assembly CLI functional")
  • Related specification: ACMS — Advanced Context Management System; CLI commands map to A2A Protocol operations

Subtasks

  • Write Behave scenarios for context list (empty and populated)
  • Write Behave scenarios for context show (existing and non-existing context)
  • Write Behave scenarios for context clear <name>
  • Write Behave scenarios for context delete <name> and context delete --all
  • Write Behave scenarios for context export <name> <file>
  • Write Behave scenarios for run --load-context <file> --context <name> (context import path)
  • Write Behave scenarios for error handling (invalid config path, malformed config, CleverAgentsException)
  • Write Behave scenarios for alternative execution paths (--load-context, --context, --context-dir combinations)
  • Write Behave scenarios for interactive mode with --load-context
  • Add any required mock implementations to features/mocks/
  • Verify coverage ≥ 97% via nox -e coverage_report
  • Run nox (all default sessions), fix any errors

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly (test(cli): add Behave coverage for context management commands and error handling), followed by a blank line, then additional lines providing relevant implementation details.
  • The commit is pushed to the remote on the branch test/coverage-cli-context-management.
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.
  • All nox stages pass.
  • Coverage ≥ 97%.

Backlog note: This issue was discovered during autonomous operation
on milestone v3.7.0. It does not block milestone completion and has been
placed in the backlog for human review and future milestone assignment.


Automated by CleverAgents Bot
Supervisor: Test Infrastructure | Agent: ca-new-issue-creator

## Metadata - **Branch**: `test/coverage-cli-context-management` - **Commit Message**: `test(cli): add Behave coverage for context management commands and error handling` - **Milestone**: *(none — backlog, see note below)* - **Parent Epic**: #396 ## Background and Context The file `src/cleveragents/cli.py` has a significant coverage gap at **62.01%**. The existing tests primarily cover the happy path of the `run` command but neglect the extensive context management features and various error handling paths. The ACMS Context Pipeline Epic (#396) explicitly lists "Context assembly CLI functional (`context list/add/show/clear`)" as an acceptance criterion — without adequate test coverage, this criterion cannot be verified with confidence. ## Current Behavior The following key areas of `src/cleveragents/cli.py` are completely untested: - **Context Management**: The entire `context` command group, including subcommands for listing, showing, clearing, deleting, and exporting contexts. - **Error Handling**: Numerous `try...except` blocks handling `CleverAgentsException`, `FileNotFoundError`, and user configuration errors. - **Alternative Execution Paths**: Conditional paths based on different combinations of `--load-context`, `--context`, `--context-dir`, and `--all` flags. - **Interactive Mode with Context**: Logic for starting an interactive session with a loaded context. - **Edge Cases**: Branches handling no-contexts-found, context-already-exists, and similar boundary conditions. ## Expected Behavior `src/cleveragents/cli.py` should have test coverage that contributes to the project-wide ≥ 97% coverage requirement. All context management subcommands and error handling paths should be exercised by Behave scenarios. ## Acceptance Criteria - [ ] `cleveragents context list` is tested for both the empty-contexts and multiple-contexts cases. - [ ] `cleveragents context show <name>` is tested for an existing context and a non-existing context. - [ ] `cleveragents context clear <name>` is tested. - [ ] `cleveragents context delete <name>` and `cleveragents context delete --all` are tested. - [ ] `cleveragents context export <name> <file>` is tested. - [ ] `cleveragents run --load-context <file> --context <name>` (context import path) is tested. - [ ] Error handling paths (invalid config path, malformed config, `CleverAgentsException` propagation) are tested. - [ ] Alternative execution paths for `--load-context`, `--context`, and `--context-dir` combinations are tested. - [ ] Interactive mode with `--load-context` is tested. - [ ] All new mocks and test doubles are placed exclusively in `features/mocks/`. - [ ] Overall project coverage remains ≥ 97% (`nox -e coverage_report`). - [ ] All nox sessions pass with zero errors. ## Supporting Information - **File with missing coverage**: `src/cleveragents/cli.py` - **Current coverage**: 62.01% - **Analysis tool**: `ca-test-infra-improver` (worker mode) - **Parent Epic**: #396 — Epic: ACMS Context Pipeline (acceptance criterion: "Context assembly CLI functional") - **Related specification**: ACMS — Advanced Context Management System; CLI commands map to A2A Protocol operations ## Subtasks - [ ] Write Behave scenarios for `context list` (empty and populated) - [ ] Write Behave scenarios for `context show` (existing and non-existing context) - [ ] Write Behave scenarios for `context clear <name>` - [ ] Write Behave scenarios for `context delete <name>` and `context delete --all` - [ ] Write Behave scenarios for `context export <name> <file>` - [ ] Write Behave scenarios for `run --load-context <file> --context <name>` (context import path) - [ ] Write Behave scenarios for error handling (invalid config path, malformed config, `CleverAgentsException`) - [ ] Write Behave scenarios for alternative execution paths (`--load-context`, `--context`, `--context-dir` combinations) - [ ] Write Behave scenarios for interactive mode with `--load-context` - [ ] Add any required mock implementations to `features/mocks/` - [ ] Verify coverage ≥ 97% via `nox -e coverage_report` - [ ] Run `nox` (all default sessions), fix any errors ## Definition of Done This issue is complete when: - [ ] All subtasks above are completed and checked off. - [ ] A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly (`test(cli): add Behave coverage for context management commands and error handling`), followed by a blank line, then additional lines providing relevant implementation details. - [ ] The commit is pushed to the remote on the branch `test/coverage-cli-context-management`. - [ ] The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done. - [ ] All nox stages pass. - [ ] Coverage ≥ 97%. > **Backlog note:** This issue was discovered during autonomous operation > on milestone v3.7.0. It does not block milestone completion and has been > placed in the backlog for human review and future milestone assignment. --- **Automated by CleverAgents Bot** Supervisor: Test Infrastructure | Agent: ca-new-issue-creator
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Blocks
#396 Epic: ACMS Context Pipeline
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#3796
No description provided.