Files
cleveragents-core/features/models_skill_coverage_r2.feature
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

109 lines
5.6 KiB
Gherkin

Feature: SkillModel to_domain/from_domain branch coverage (round 2)
As a developer maintaining the ORM layer
I want every branch in the domain-conversion helpers tested
So that models.py achieves near-100 % branch coverage
# ===================================================================
# SkillModel.to_domain() lines 2185-2224
# Targets: uncovered lines 2188-2189, branch partials on item_type
# checks, item_config_str checks, metadata_str check
# ===================================================================
Scenario: r2mod- SkillModel.to_domain with None items_rel returns empty lists
Given a r2mod-SkillModel with no items and no metadata
When I r2mod-convert the SkillModel to domain
Then the r2mod-skill tool_refs should be empty
And the r2mod-skill includes should be empty
And the r2mod-skill anonymous_tools should be empty
And the r2mod-skill mcp_servers should be empty
And the r2mod-skill agent_skills should be empty
And the r2mod-skill overrides should be empty
Scenario: r2mod- SkillModel.to_domain with tool_ref items
Given a r2mod-SkillModel with a tool_ref item named "local/my-tool"
When I r2mod-convert the SkillModel to domain
Then the r2mod-skill tool_refs should contain "local/my-tool"
Scenario: r2mod- SkillModel.to_domain with include item with config overrides
Given a r2mod-SkillModel with an include item "local/inc" with config overrides
When I r2mod-convert the SkillModel to domain
Then the r2mod-skill includes should have 1 entry
And the r2mod-skill first include name should be "local/inc"
And the r2mod-skill first include overrides should not be None
Scenario: r2mod- SkillModel.to_domain with include item without config
Given a r2mod-SkillModel with an include item "local/inc" without config
When I r2mod-convert the SkillModel to domain
Then the r2mod-skill includes should have 1 entry
And the r2mod-skill first include overrides should be None
Scenario: r2mod- SkillModel.to_domain with inline_tool item without config (skipped)
Given a r2mod-SkillModel with an inline_tool item without config
When I r2mod-convert the SkillModel to domain
Then the r2mod-skill anonymous_tools should be empty
Scenario: r2mod- SkillModel.to_domain with mcp_source item without config (skipped)
Given a r2mod-SkillModel with an mcp_source item without config
When I r2mod-convert the SkillModel to domain
Then the r2mod-skill mcp_servers should be empty
Scenario: r2mod- SkillModel.to_domain with agent_source item
Given a r2mod-SkillModel with an agent_source item "path/to/agent"
When I r2mod-convert the SkillModel to domain
Then the r2mod-skill agent_skills should have 1 entry
And the r2mod-skill first agent_skill path should be "path/to/agent"
Scenario: r2mod- SkillModel.to_domain with metadata_json containing overrides
Given a r2mod-SkillModel with metadata_json containing overrides
When I r2mod-convert the SkillModel to domain
Then the r2mod-skill overrides should not be empty
Scenario: r2mod- SkillModel.to_domain with inline_tool and mcp_source with config
Given a r2mod-SkillModel with inline_tool and mcp_source items with config
When I r2mod-convert the SkillModel to domain
Then the r2mod-skill anonymous_tools should have 1 entry
And the r2mod-skill mcp_servers should have 1 entry
# ===================================================================
# SkillModel.from_domain() — lines 2227-2366
# Targets: ValueError branch, overrides branch, include-as-string,
# anonymous_tools-as-dict, mcp_servers-as-dict,
# agent_skills-as-string
# ===================================================================
Scenario: r2mod- SkillModel.from_domain raises ValueError for invalid name
When I r2mod-attempt from_domain on SkillModel with name "badname"
Then a r2mod-ValueError should have been raised
Scenario: r2mod- SkillModel.from_domain with no overrides
When I r2mod-create SkillModel from domain with name "ns/sk" and no overrides
Then the r2mod-created SkillModel metadata_json should be None
Scenario: r2mod- SkillModel.from_domain with overrides
When I r2mod-create SkillModel from domain with name "ns/sk" and overrides
Then the r2mod-created SkillModel metadata_json should contain "overrides"
Scenario: r2mod- SkillModel.from_domain with include as string
When I r2mod-create SkillModel from domain with includes as strings
Then the r2mod-created SkillModel should have include items
Scenario: r2mod- SkillModel.from_domain with anonymous_tools as dict
When I r2mod-create SkillModel from domain with anonymous_tools as dicts
Then the r2mod-created SkillModel should have inline_tool items
Scenario: r2mod- SkillModel.from_domain with mcp_servers as dict
When I r2mod-create SkillModel from domain with mcp_servers as dicts
Then the r2mod-created SkillModel should have mcp_source items
Scenario: r2mod- SkillModel.from_domain with agent_skills as string
When I r2mod-create SkillModel from domain with agent_skills as strings
Then the r2mod-created SkillModel should have agent_source items
Scenario: r2mod- SkillModel.from_domain with anonymous_tools fallback branch
When I r2mod-create SkillModel from domain with anonymous_tools as plain objects
Then the r2mod-created SkillModel should have inline_tool items
Scenario: r2mod- SkillModel.from_domain with mcp_servers fallback branch
When I r2mod-create SkillModel from domain with mcp_servers as plain objects
Then the r2mod-created SkillModel should have mcp_source items