Files
cleveragents-core/features/correction_service_coverage_r2.feature
T
freemo 3a2b134f3c
CI / lint (pull_request) Successful in 14s
CI / benchmark-publish (pull_request) Has been skipped
CI / quality (pull_request) Successful in 27s
CI / typecheck (pull_request) Successful in 37s
CI / security (pull_request) Successful in 39s
CI / build (pull_request) Successful in 29s
CI / integration_tests (pull_request) Successful in 5m51s
CI / benchmark-regression (pull_request) Successful in 22m39s
CI / unit_tests (pull_request) Successful in 29m35s
CI / docker (pull_request) Successful in 13s
CI / coverage (pull_request) Successful in 2h3m1s
CI / lint (push) Successful in 21s
CI / typecheck (push) Successful in 57s
CI / security (push) Successful in 51s
CI / quality (push) Successful in 27s
CI / integration_tests (push) Successful in 4m59s
CI / build (push) Successful in 23s
CI / benchmark-publish (push) Successful in 14m39s
CI / benchmark-regression (push) Has been skipped
CI / unit_tests (push) Successful in 29m48s
CI / docker (push) Successful in 15s
CI / coverage (push) Successful in 1h45m42s
test(coverage): add Behave scenarios for remaining under-tested modules
Added Behave BDD feature files and step definitions targeting coverage
gaps in six modules:

- container.py: exercise get_database_url env-var fallback, AI provider
  None path, cached container singleton, override_providers edge cases
  (lines 66-69, 125-130; branches at 51, 57, 82, 87, 256, 284-288)
- correction_service.py: exercise exception-handling paths in
  execute_revert and execute_append via monkeypatched analyze_impact
  and ULID failures (lines 254-262, 320-328)
- plan_lifecycle_service.py: exercise _persisted UoW commit paths,
  InvalidPhaseTransitionError custom message branch, non-reusable
  action archive, and error_details merge logic (branches at 100,
  216, 237, 327, 461, 570, 576, 607)
- plan.py (CLI): exercise spec-dict optional field branches,
  _print_lifecycle_plan conditional rendering, use_action argument
  parsing, auto-resolve paths, legacy wrappers, and validation
  error branches across 66 scenarios
- skill.py (CLI): exercise singleton cache, timestamp-absent show,
  no-tools MCP, add/remove/list/show format and error branches
  across 26 scenarios
- models.py (DB): exercise to_domain/from_domain None-field branches
  in SkillModel, SessionModel, ToolModel, LifecycleActionModel,
  LifecyclePlanModel, NamespacedProjectModel, and SessionMessageModel
  across 41 scenarios

All 302 features, 6503 scenarios, 28271 steps pass (nox -e unit_tests).

ISSUES CLOSED: #446
2026-02-25 19:38:43 -05:00

90 lines
5.1 KiB
Gherkin
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
Feature: CorrectionService exception-handling coverage (round 2)
As a developer maintaining CorrectionService
I want the exception-handling paths in execute_revert and execute_append fully tested
So that lines 254-262 and 320-328 of correction_service.py achieve coverage
Background:
Given r2corr-a fresh correction service
# -------------------------------------------------------------------
# execute_revert exception path (lines 254-262)
# -------------------------------------------------------------------
Scenario: execute_revert catches internal error and returns FAILED result
Given r2corr-a stored revert correction for plan "P1" targeting "D1"
And r2corr-analyze_impact is patched to raise RuntimeError "boom in analyze"
When r2corr-I execute revert on the stored correction
Then r2corr-the revert result status should be "failed"
And r2corr-the revert result error_message should contain "boom in analyze"
And r2corr-the stored correction status should be "failed"
And r2corr-the first attempt should have success false
And r2corr-the first attempt details should contain error key
And r2corr-the first attempt details error should contain "boom in analyze"
And r2corr-the first attempt completed_at should be set
And r2corr-the result should be stored in the service results dict
Scenario: execute_revert exception path preserves attempt count
Given r2corr-a stored revert correction for plan "P1" targeting "D2"
And r2corr-analyze_impact is patched to raise ValueError "bad value"
When r2corr-I execute revert on the stored correction
Then r2corr-the attempts for the stored correction should have 1 entry
And r2corr-the first attempt should have success false
Scenario: execute_revert exception with TypeError message
Given r2corr-a stored revert correction for plan "P1" targeting "D3"
And r2corr-analyze_impact is patched to raise TypeError "wrong type"
When r2corr-I execute revert on the stored correction
Then r2corr-the revert result status should be "failed"
And r2corr-the revert result error_message should contain "wrong type"
And r2corr-the stored correction status should be "failed"
# -------------------------------------------------------------------
# execute_append exception path (lines 320-328)
# -------------------------------------------------------------------
Scenario: execute_append catches internal error and returns FAILED result
Given r2corr-a stored append correction for plan "P1" targeting "A1"
And r2corr-ULID is patched to raise RuntimeError "ulid broken"
When r2corr-I execute append on the stored correction
Then r2corr-the append result status should be "failed"
And r2corr-the append result error_message should contain "ulid broken"
And r2corr-the stored correction status should be "failed"
And r2corr-the first attempt should have success false
And r2corr-the first attempt details should contain error key
And r2corr-the first attempt details error should contain "ulid broken"
And r2corr-the first attempt completed_at should be set
And r2corr-the append result should be stored in the service results dict
Scenario: execute_append exception path preserves attempt count
Given r2corr-a stored append correction for plan "P1" targeting "A2"
And r2corr-ULID is patched to raise ValueError "ulid value error"
When r2corr-I execute append on the stored correction
Then r2corr-the attempts for the stored correction should have 1 entry
And r2corr-the first attempt should have success false
Scenario: execute_append exception with OSError message
Given r2corr-a stored append correction for plan "P1" targeting "A3"
And r2corr-ULID is patched to raise OSError "system failure"
When r2corr-I execute append on the stored correction
Then r2corr-the append result status should be "failed"
And r2corr-the append result error_message should contain "system failure"
And r2corr-the stored correction status should be "failed"
# -------------------------------------------------------------------
# execute_correction dispatch into exception paths
# -------------------------------------------------------------------
Scenario: dispatch to revert hits exception path when analyze_impact fails
Given r2corr-a stored revert correction for plan "P1" targeting "DR1"
And r2corr-analyze_impact is patched to raise RuntimeError "dispatch revert boom"
When r2corr-I dispatch execute correction on the stored correction
Then r2corr-the dispatch result status should be "failed"
And r2corr-the dispatch result error_message should contain "dispatch revert boom"
Scenario: dispatch to append hits exception path when ULID fails
Given r2corr-a stored append correction for plan "P1" targeting "DA1"
And r2corr-ULID is patched to raise RuntimeError "dispatch append boom"
When r2corr-I dispatch execute correction on the stored correction
Then r2corr-the dispatch result status should be "failed"
And r2corr-the dispatch result error_message should contain "dispatch append boom"