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

92 lines
4.7 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: Container module coverage round 2
As a developer maintaining container.py
I want every uncovered line and branch exercised
So that container.py achieves full coverage
# -------------------------------------------------------------------
# get_ai_provider non-mock paths (lines 51 False, 66-67, 69)
# -------------------------------------------------------------------
Scenario: AI provider returns None when mock disabled and no providers configured
Given r2cont- the mock AI environment flag is disabled
And r2cont- a provider registry with no configured providers
When r2cont- I call get_ai_provider with the mocked registry
Then r2cont- the ai provider result should be None
Scenario: AI provider returns real provider when mock disabled and providers exist
Given r2cont- the mock AI environment flag is disabled
And r2cont- a provider registry with configured providers
When r2cont- I call get_ai_provider with the mocked registry
Then r2cont- the ai provider result should not be None
# -------------------------------------------------------------------
# get_ai_provider features path already on sys.path (line 57 partial)
# -------------------------------------------------------------------
Scenario: AI provider with features path already on sys.path does not duplicate it
Given r2cont- the mock AI environment flag is enabled
And r2cont- the features path is already on sys.path
When r2cont- I call get_ai_provider without registry args
Then r2cont- the features path should appear exactly once on sys.path
# -------------------------------------------------------------------
# _build_project_resource_link_repo (lines 125-130)
# -------------------------------------------------------------------
Scenario: Build project resource link repo creates valid repository
When r2cont- I build a project resource link repo with an in-memory database
Then r2cont- the result should be a ProjectResourceLinkRepository instance
# -------------------------------------------------------------------
# get_database_url env var branches (lines 82, 87)
# -------------------------------------------------------------------
Scenario: get_database_url returns fallback when no env vars are set
Given r2cont- no database URL environment variables are set
When r2cont- I call get_database_url
Then r2cont- the database URL should start with "sqlite:///"
Scenario: get_database_url returns CLEVERAGENTS_DATABASE_URL when set
Given r2cont- the env var "CLEVERAGENTS_DATABASE_URL" is set to "sqlite:///explicit.db"
When r2cont- I call get_database_url
Then r2cont- the database URL should be "sqlite:///explicit.db"
Scenario: get_database_url returns CLEVERAGENTS_TEST_DATABASE_URL when primary is unset
Given r2cont- the env var "CLEVERAGENTS_DATABASE_URL" is cleared
And r2cont- the env var "CLEVERAGENTS_TEST_DATABASE_URL" is set to "sqlite:///test.db"
When r2cont- I call get_database_url
Then r2cont- the database URL should be "sqlite:///test.db"
Scenario: get_database_url skips empty env var values
Given r2cont- the env var "CLEVERAGENTS_DATABASE_URL" is set to empty
And r2cont- the env var "CLEVERAGENTS_TEST_DATABASE_URL" is set to empty
When r2cont- I call get_database_url
Then r2cont- the database URL should start with "sqlite:///"
# -------------------------------------------------------------------
# get_container cached instance (line 256 False branch)
# -------------------------------------------------------------------
Scenario: get_container returns the cached instance on subsequent calls
Given r2cont- the global container has been reset
When r2cont- I call get_container twice
Then r2cont- both calls should return the same container instance
# -------------------------------------------------------------------
# override_providers non-existent attribute (line 285 False)
# -------------------------------------------------------------------
Scenario: override_providers ignores non-existent provider names
Given r2cont- the global container has been reset
When r2cont- I override a provider with a non-existent name
Then r2cont- no error should have been raised
# -------------------------------------------------------------------
# override_providers non-database_url provider (line 288 else)
# -------------------------------------------------------------------
Scenario: override_providers handles non-database_url providers via Object
Given r2cont- the global container has been reset
When r2cont- I override the settings provider with a mock value
Then r2cont- the settings provider should return the mock value