Improve unit test coverage for container, correction service, plan lifecycle, CLI, and database modules #446

Closed
opened 2026-02-25 22:53:15 +00:00 by freemo · 0 comments
Owner

Metadata

  • Commit Message: test(coverage): add Behave scenarios for remaining under-tested modules
  • Branch: test/improve-coverage-round2

Background and Context

Following the first round of coverage improvements (#418), six additional modules still have coverage gaps on specific branches, error-handling paths, or validation guards. This round targets the remaining under-tested areas to strengthen the project's test safety net and maintain the 97% coverage threshold.

Target Files and Coverage Gaps

Module Line Coverage Branch Coverage Key Gaps
application/container.py 91.8% 77.8% Lines 66-67, 69, 125-130; branches at 51, 57, 82, 87, 256, 284-285, 288
application/services/correction_service.py 93.0% 100% Lines 254-255, 260-262, 320-321, 326-328 (exception handling in revert/append)
application/services/plan_lifecycle_service.py 98.2% 94.3% Partial branches at 100, 216, 304, 333, 336, 339 (_persisted checks, validation guards)
cli/commands/plan.py 92.1% 91.7% Partial branches around validation checks (69, 106, 137, 172) and conditional logic
cli/commands/skill.py 100% 93.0% Branch partials at 74, 109, 112, 121, 155, 164, 169
infrastructure/database/models.py 98.5% 88.3% Branch partials in to_domain/from_domain helpers; lines 2188-2189

Note: Two originally requested files (lock_service.py and changeset_repository.py) do not exist in the codebase and are excluded.

Expected Behavior

All six target modules should have new Behave scenarios exercising their previously uncovered lines and branches. All new and existing tests should pass (nox -e unit_tests).

Acceptance Criteria

  • container.py uncovered lines (66-67, 69, 125-130) and partial branches are exercised
  • correction_service.py uncovered exception-handling paths (lines 254-255, 260-262, 320-321, 326-328) are exercised
  • plan_lifecycle_service.py partial branches (_persisted checks, validation guards) are exercised
  • plan.py (CLI) uncovered validation branches are exercised
  • skill.py (CLI) uncovered branch partials are exercised
  • models.py (DB) uncovered branches in to_domain/from_domain and lines 2188-2189 are exercised
  • All existing tests continue to pass (nox -e unit_tests green)
  • Coverage remains >=97%
  • No production source code is modified

Subtasks

  • Write Behave feature + step files for container.py (targeting uncovered lines and branches)
  • Write Behave feature + step files for correction_service.py (targeting exception-handling paths)
  • Write Behave feature + step files for plan_lifecycle_service.py (targeting partial branches)
  • Write Behave feature + step files for plan.py CLI (targeting validation branches)
  • Write Behave feature + step files for skill.py CLI (targeting branch partials)
  • Write Behave feature + step files for models.py DB (targeting to_domain/from_domain branches)
  • Run nox -e unit_tests — all features, scenarios, and steps pass
  • Verify coverage >=97% via nox -e coverage_report

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, followed by a blank line, then additional lines providing relevant details about the implementation.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly.
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.
## Metadata - **Commit Message**: `test(coverage): add Behave scenarios for remaining under-tested modules` - **Branch**: `test/improve-coverage-round2` ## Background and Context Following the first round of coverage improvements (#418), six additional modules still have coverage gaps on specific branches, error-handling paths, or validation guards. This round targets the remaining under-tested areas to strengthen the project's test safety net and maintain the 97% coverage threshold. ### Target Files and Coverage Gaps | Module | Line Coverage | Branch Coverage | Key Gaps | |--------|--------------|-----------------|----------| | `application/container.py` | 91.8% | 77.8% | Lines 66-67, 69, 125-130; branches at 51, 57, 82, 87, 256, 284-285, 288 | | `application/services/correction_service.py` | 93.0% | 100% | Lines 254-255, 260-262, 320-321, 326-328 (exception handling in revert/append) | | `application/services/plan_lifecycle_service.py` | 98.2% | 94.3% | Partial branches at 100, 216, 304, 333, 336, 339 (`_persisted` checks, validation guards) | | `cli/commands/plan.py` | 92.1% | 91.7% | Partial branches around validation checks (69, 106, 137, 172) and conditional logic | | `cli/commands/skill.py` | 100% | 93.0% | Branch partials at 74, 109, 112, 121, 155, 164, 169 | | `infrastructure/database/models.py` | 98.5% | 88.3% | Branch partials in to_domain/from_domain helpers; lines 2188-2189 | **Note:** Two originally requested files (`lock_service.py` and `changeset_repository.py`) do not exist in the codebase and are excluded. ## Expected Behavior All six target modules should have new Behave scenarios exercising their previously uncovered lines and branches. All new and existing tests should pass (`nox -e unit_tests`). ## Acceptance Criteria - [ ] `container.py` uncovered lines (66-67, 69, 125-130) and partial branches are exercised - [ ] `correction_service.py` uncovered exception-handling paths (lines 254-255, 260-262, 320-321, 326-328) are exercised - [ ] `plan_lifecycle_service.py` partial branches (`_persisted` checks, validation guards) are exercised - [ ] `plan.py` (CLI) uncovered validation branches are exercised - [ ] `skill.py` (CLI) uncovered branch partials are exercised - [ ] `models.py` (DB) uncovered branches in to_domain/from_domain and lines 2188-2189 are exercised - [ ] All existing tests continue to pass (`nox -e unit_tests` green) - [ ] Coverage remains >=97% - [ ] No production source code is modified ## Subtasks - [ ] Write Behave feature + step files for `container.py` (targeting uncovered lines and branches) - [ ] Write Behave feature + step files for `correction_service.py` (targeting exception-handling paths) - [ ] Write Behave feature + step files for `plan_lifecycle_service.py` (targeting partial branches) - [ ] Write Behave feature + step files for `plan.py` CLI (targeting validation branches) - [ ] Write Behave feature + step files for `skill.py` CLI (targeting branch partials) - [ ] Write Behave feature + step files for `models.py` DB (targeting to_domain/from_domain branches) - [ ] Run `nox -e unit_tests` — all features, scenarios, and steps pass - [ ] Verify coverage >=97% via `nox -e coverage_report` ## 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, followed by a blank line, then additional lines providing relevant details about the implementation. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly. - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done.
freemo added this to the v3.1.0 milestone 2026-02-25 23:48:46 +00:00
freemo added reference test/improve-coverage-round2 2026-02-25 23:49:13 +00:00
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.

Reference
cleveragents/cleveragents-core#446
No description provided.