forked from cleveragents/cleveragents-core
3a2b134f3c
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
229 lines
10 KiB
Gherkin
229 lines
10 KiB
Gherkin
Feature: Plan CLI commands branch coverage (round 2)
|
||
As a developer
|
||
I want to exercise uncovered branches in CLI command functions
|
||
So that branch coverage for use_action, execute, apply, list, revert, status, correct, and diff rises
|
||
|
||
# ===================================================================
|
||
# use_action argument parsing – int / float / bool / string
|
||
# ===================================================================
|
||
|
||
Scenario: r2plan use_action parses integer argument
|
||
Given r2plan-a mocked lifecycle service
|
||
When r2plan-I invoke use with action "local/test" and arg "count=42"
|
||
Then r2plan-the parsed arguments should have "count" as int 42
|
||
|
||
Scenario: r2plan use_action parses float argument
|
||
Given r2plan-a mocked lifecycle service
|
||
When r2plan-I invoke use with action "local/test" and arg "ratio=3.14"
|
||
Then r2plan-the parsed arguments should have "ratio" as float 3.14
|
||
|
||
Scenario: r2plan use_action parses bool true argument
|
||
Given r2plan-a mocked lifecycle service
|
||
When r2plan-I invoke use with action "local/test" and arg "verbose=true"
|
||
Then r2plan-the parsed arguments should have "verbose" as bool true
|
||
|
||
Scenario: r2plan use_action parses bool false argument
|
||
Given r2plan-a mocked lifecycle service
|
||
When r2plan-I invoke use with action "local/test" and arg "verbose=false"
|
||
Then r2plan-the parsed arguments should have "verbose" as bool false
|
||
|
||
Scenario: r2plan use_action parses string argument
|
||
Given r2plan-a mocked lifecycle service
|
||
When r2plan-I invoke use with action "local/test" and arg "name=hello"
|
||
Then r2plan-the parsed arguments should have "name" as string "hello"
|
||
|
||
Scenario: r2plan use_action rejects argument missing equals sign
|
||
Given r2plan-a mocked lifecycle service
|
||
When r2plan-I invoke use with action "local/test" and arg "badarg"
|
||
Then r2plan-the command should abort
|
||
And r2plan-the output should contain "Invalid argument format"
|
||
|
||
# ===================================================================
|
||
# use_action – invalid automation profile
|
||
# ===================================================================
|
||
|
||
Scenario: r2plan use_action rejects invalid automation profile
|
||
Given r2plan-a mocked lifecycle service
|
||
When r2plan-I invoke use with action "local/test" and automation profile "bogus"
|
||
Then r2plan-the command should abort
|
||
And r2plan-the output should contain "Invalid automation profile"
|
||
|
||
# ===================================================================
|
||
# use_action – actor overrides with invalid names
|
||
# ===================================================================
|
||
|
||
Scenario: r2plan use_action rejects invalid strategy actor
|
||
Given r2plan-a mocked lifecycle service
|
||
When r2plan-I invoke use with action "local/test" and strategy actor "INVALID"
|
||
Then r2plan-the command should abort
|
||
And r2plan-the output should contain "Validation Error"
|
||
|
||
Scenario: r2plan use_action rejects invalid execution actor
|
||
Given r2plan-a mocked lifecycle service
|
||
When r2plan-I invoke use with action "local/test" and execution actor "bad-name"
|
||
Then r2plan-the command should abort
|
||
And r2plan-the output should contain "Validation Error"
|
||
|
||
# ===================================================================
|
||
# execute_plan – auto-resolve: no plans / multiple plans
|
||
# ===================================================================
|
||
|
||
Scenario: r2plan execute_plan aborts when no plans ready
|
||
Given r2plan-a mocked lifecycle service
|
||
And r2plan-the service lists no complete strategize plans
|
||
When r2plan-I invoke execute without plan_id
|
||
Then r2plan-the command should abort
|
||
And r2plan-the output should contain "No plans ready for execution"
|
||
|
||
Scenario: r2plan execute_plan aborts when multiple plans ready
|
||
Given r2plan-a mocked lifecycle service
|
||
And r2plan-the service lists multiple complete strategize plans
|
||
When r2plan-I invoke execute without plan_id
|
||
Then r2plan-the command should abort
|
||
And r2plan-the output should contain "Multiple plans ready"
|
||
|
||
# ===================================================================
|
||
# lifecycle_apply_plan – auto-resolve: no plans / multiple plans
|
||
# ===================================================================
|
||
|
||
Scenario: r2plan lifecycle_apply aborts when no plans ready
|
||
Given r2plan-a mocked lifecycle service
|
||
And r2plan-the service lists no complete execute plans
|
||
When r2plan-I invoke lifecycle-apply without plan_id
|
||
Then r2plan-the command should abort
|
||
And r2plan-the output should contain "No plans ready for apply"
|
||
|
||
Scenario: r2plan lifecycle_apply aborts when multiple plans ready
|
||
Given r2plan-a mocked lifecycle service
|
||
And r2plan-the service lists multiple complete execute plans
|
||
When r2plan-I invoke lifecycle-apply without plan_id
|
||
Then r2plan-the command should abort
|
||
And r2plan-the output should contain "Multiple plans ready"
|
||
|
||
# ===================================================================
|
||
# lifecycle_list_plans – invalid phase / invalid state
|
||
# ===================================================================
|
||
|
||
Scenario: r2plan lifecycle_list rejects invalid phase
|
||
Given r2plan-a mocked lifecycle service
|
||
When r2plan-I invoke lifecycle-list with phase "nonexistent"
|
||
Then r2plan-the command should abort
|
||
And r2plan-the output should contain "Invalid phase"
|
||
|
||
Scenario: r2plan lifecycle_list rejects invalid state
|
||
Given r2plan-a mocked lifecycle service
|
||
When r2plan-I invoke lifecycle-list with state "nonexistent"
|
||
Then r2plan-the command should abort
|
||
And r2plan-the output should contain "Invalid state"
|
||
|
||
# ===================================================================
|
||
# lifecycle_list_plans – empty result
|
||
# ===================================================================
|
||
|
||
Scenario: r2plan lifecycle_list shows no-plans message when empty
|
||
Given r2plan-a mocked lifecycle service
|
||
And r2plan-the service lists no plans
|
||
When r2plan-I invoke lifecycle-list
|
||
Then r2plan-the command should succeed
|
||
And r2plan-the output should contain "No plans found"
|
||
|
||
# ===================================================================
|
||
# revert_plan – invalid --to-phase
|
||
# ===================================================================
|
||
|
||
Scenario: r2plan revert_plan rejects invalid to-phase
|
||
Given r2plan-a mocked lifecycle service
|
||
When r2plan-I invoke revert with plan "PLAN123" and invalid phase "badphase"
|
||
Then r2plan-the command should abort
|
||
And r2plan-the output should contain "Invalid phase"
|
||
|
||
Scenario: r2plan revert_plan non-rich format
|
||
Given r2plan-a mocked lifecycle service
|
||
And r2plan-the service can revert a plan
|
||
When r2plan-I invoke revert with plan "PLAN123" and format "json"
|
||
Then r2plan-the command should succeed
|
||
And r2plan-the output should contain "plan_id"
|
||
|
||
# ===================================================================
|
||
# plan_status – without plan_id: no plans, plans in non-rich, rich
|
||
# ===================================================================
|
||
|
||
Scenario: r2plan status shows no-plans message
|
||
Given r2plan-a mocked lifecycle service
|
||
And r2plan-the service lists no plans
|
||
When r2plan-I invoke status without plan_id
|
||
Then r2plan-the command should succeed
|
||
And r2plan-the output should contain "No v3 lifecycle plans found"
|
||
|
||
Scenario: r2plan status without plan_id lists plans in non-rich
|
||
Given r2plan-a mocked lifecycle service
|
||
And r2plan-the service lists some plans
|
||
When r2plan-I invoke status without plan_id and format "json"
|
||
Then r2plan-the command should succeed
|
||
And r2plan-the output should contain "plan_id"
|
||
|
||
Scenario: r2plan status with plan_id in non-rich format
|
||
Given r2plan-a mocked lifecycle service
|
||
And r2plan-the service can get a plan by id
|
||
When r2plan-I invoke status with plan_id and format "json"
|
||
Then r2plan-the command should succeed
|
||
And r2plan-the output should contain "plan_id"
|
||
|
||
# ===================================================================
|
||
# correct_decision – invalid mode / empty guidance
|
||
# ===================================================================
|
||
|
||
Scenario: r2plan correct rejects invalid mode
|
||
Given r2plan-a mocked lifecycle service
|
||
When r2plan-I invoke correct with mode "badmode"
|
||
Then r2plan-the command should abort
|
||
And r2plan-the output should contain "Invalid mode"
|
||
|
||
Scenario: r2plan correct rejects empty guidance
|
||
Given r2plan-a mocked lifecycle service
|
||
When r2plan-I invoke correct with empty guidance
|
||
Then r2plan-the command should abort
|
||
And r2plan-the output should contain "guidance"
|
||
|
||
# ===================================================================
|
||
# plan_diff – correction flag present
|
||
# ===================================================================
|
||
|
||
Scenario: r2plan diff shows correction stub when correction flag set
|
||
Given r2plan-a mocked lifecycle service
|
||
When r2plan-I invoke diff with plan "P1" and correction "CORR1"
|
||
Then r2plan-the command should succeed
|
||
And r2plan-the output should contain "Correction Attempt"
|
||
And r2plan-the output should contain "CORR1"
|
||
|
||
# ===================================================================
|
||
# execute_plan – auto-resolve with exactly one plan
|
||
# ===================================================================
|
||
|
||
Scenario: r2plan execute_plan auto-resolves single plan
|
||
Given r2plan-a mocked lifecycle service
|
||
And r2plan-the service lists exactly one complete strategize plan
|
||
When r2plan-I invoke execute without plan_id
|
||
Then r2plan-the command should succeed
|
||
|
||
# ===================================================================
|
||
# lifecycle_apply – auto-resolve with exactly one plan
|
||
# ===================================================================
|
||
|
||
Scenario: r2plan lifecycle_apply auto-resolves single plan
|
||
Given r2plan-a mocked lifecycle service
|
||
And r2plan-the service lists exactly one complete execute plan
|
||
When r2plan-I invoke lifecycle-apply without plan_id
|
||
Then r2plan-the command should succeed
|
||
|
||
# ===================================================================
|
||
# lifecycle_list_plans – projects > 2 truncation
|
||
# ===================================================================
|
||
|
||
Scenario: r2plan lifecycle_list truncates projects over 2
|
||
Given r2plan-a mocked lifecycle service
|
||
And r2plan-the service lists a plan with 4 project links
|
||
When r2plan-I invoke lifecycle-list
|
||
Then r2plan-the command should succeed
|
||
And r2plan-the output should contain "+2 more"
|