Files
cleveragents-core/features/models_record_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

92 lines
4.6 KiB
Gherkin

Feature: Session, Tool, and Project model 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
# ===================================================================
# SessionModel.to_domain() lines 1858-1896
# Targets: None branches on linked_plan_ids_json, token_usage_json,
# metadata_json, messages_rel
# ===================================================================
Scenario: r2mod- SessionModel.to_domain with all None JSON fields
Given a r2mod-SessionModel with all JSON fields as None
When I r2mod-convert the SessionModel to domain
Then the r2mod-session linked_plan_ids should be empty
And the r2mod-session token_usage input_tokens should be 0
And the r2mod-session metadata should be empty
And the r2mod-session messages should be empty
# ===================================================================
# SessionMessageModel.to_domain() — line 1983
# Targets: None metadata_json branch
# ===================================================================
Scenario: r2mod- SessionMessageModel.to_domain with None metadata_json
Given a r2mod-SessionMessageModel with None metadata_json
When I r2mod-convert the SessionMessageModel to domain
Then the r2mod-message metadata should be empty
# ===================================================================
# ToolModel.to_domain() / from_domain() — lines 1612-1718
# Targets: None resource_bindings_rel branch, dict-vs-object input,
# no-slash name branch
# ===================================================================
Scenario: r2mod- ToolModel.to_domain with None resource_bindings_rel
Given a r2mod-ToolModel with no resource bindings
When I r2mod-convert the ToolModel to domain
Then the r2mod-tool resource_bindings should be empty
Scenario: r2mod- ToolModel.from_domain with dict input and no slash in name
When I r2mod-create ToolModel from dict with name "nonamespace"
Then the r2mod-created ToolModel namespace should be empty string
And the r2mod-created ToolModel short_name should be "nonamespace"
Scenario: r2mod- ToolModel.from_domain with dict input and slash in name
When I r2mod-create ToolModel from dict with name "ns/tool-name"
Then the r2mod-created ToolModel namespace should be "ns"
And the r2mod-created ToolModel short_name should be "tool-name"
Scenario: r2mod- ToolModel.from_domain with object input
When I r2mod-create ToolModel from object with name "ns/objtool"
Then the r2mod-created ToolModel namespace should be "ns"
Scenario: r2mod- ToolModel.from_domain with resource_bindings as None
When I r2mod-create ToolModel from dict with no resource_bindings
Then the r2mod-created ToolModel resource_bindings_rel should be empty
# ===================================================================
# NamespacedProjectModel.to_domain() — lines 1109-1153
# Targets: no context_policy_json, no resource_links, no-slash name
# ===================================================================
Scenario: r2mod- ProjectModel.to_domain with no context policy and no-slash name
Given a r2mod-ProjectModel with no context_policy_json and name "simplename"
When I r2mod-convert the ProjectModel to domain
Then the r2mod-project name should be "simplename"
And the r2mod-project linked_resources should be empty
Scenario: r2mod- ProjectModel.to_domain with None resource_links
Given a r2mod-ProjectModel with None resource_links
When I r2mod-convert the ProjectModel to domain
Then the r2mod-project linked_resources should be empty
# ===================================================================
# NamespacedProjectModel.from_domain() — lines 1156-1187
# Targets: None context_config branch
# ===================================================================
Scenario: r2mod- ProjectModel.from_domain with None context_config
When I r2mod-create ProjectModel from domain with None context_config
Then the r2mod-created ProjectModel context_policy_json should be None
# ===================================================================
# SessionMessageModel.from_domain() — lines 1996-2014
# Targets: role with value attr vs plain string
# ===================================================================
Scenario: r2mod- SessionMessageModel.from_domain with string role
When I r2mod-create SessionMessageModel from domain with string role
Then the r2mod-created SessionMessageModel role should be "user"