Files
cleveragents-core/features/session_cli_coverage_boost.feature
freemo 051ee7c290 test(coverage): add Behave BDD tests to improve coverage across 52 source files
Added 52 new .feature files and corresponding _steps.py files targeting
previously uncovered code paths in the following areas:

- TUI layer: app, commands, persona (state/schema/registry), widgets,
  input (shell_exec, reference_parser)
- Application services: plan lifecycle/service/executor, session,
  project, repo indexing, correction, checkpoint, actor, llm_actors,
  strategy coordinator, resource file watcher, service retry wiring
- CLI commands: session, resource, repl, plan, db, automation_profile
- Domain models: retry_policy, resource_type, cost_budget,
  docker_compose_analyzer, detail_level, _sql_string_aware,
  _postgresql_helpers
- Core: circuit_breaker, retry_service_patterns
- Infrastructure: repositories, transaction_sandbox, strategy_registry,
  plugins/loader, container
- Config: settings
- Agents: plan_generation, context_analysis, auto_debug
- A2A: facade

All new tests follow the Behave/Gherkin BDD standard. Resolved step
definition collisions with unique prefixes. Fixed Alembic fileConfig
logger disabling issue (disable_existing_loggers=False).

ISSUES CLOSED: #1068
2026-03-20 21:22:10 +00:00

248 lines
12 KiB
Gherkin

Feature: Session CLI Coverage Boost
Additional scenarios that exercise previously uncovered code paths
in the session.py CLI commands module.
Background:
Given the session CLI coverage boost module is set up
# ---------------------------------------------------------------
# create command
# ---------------------------------------------------------------
Scenario: create command succeeds with rich format
Given session coverage boost a mock service that creates a session
When session coverage boost I invoke the create command with rich format
Then session coverage boost the exit code is 0
And session coverage boost the output contains "Session Created"
Scenario: create command succeeds with JSON format
Given session coverage boost a mock service that creates a session
When session coverage boost I invoke the create command with json format
Then session coverage boost the exit code is 0
Scenario: create command catches DatabaseError
Given session coverage boost a mock service that raises DatabaseError on create
When session coverage boost I invoke the create command with rich format
Then session coverage boost the exit code is 1
And session coverage boost the output contains "Database unavailable"
# ---------------------------------------------------------------
# list command
# ---------------------------------------------------------------
Scenario: list command succeeds with sessions in rich format
Given session coverage boost a mock service that lists sessions
When session coverage boost I invoke the list command with rich format
Then session coverage boost the exit code is 0
And session coverage boost the output contains "Sessions"
Scenario: list command succeeds with sessions in JSON format
Given session coverage boost a mock service that lists sessions
When session coverage boost I invoke the list command with json format
Then session coverage boost the exit code is 0
Scenario: list command with no sessions in rich format
Given session coverage boost a mock service that lists empty sessions
When session coverage boost I invoke the list command with rich format
Then session coverage boost the exit code is 0
And session coverage boost the output contains "No sessions found"
Scenario: list command with no sessions in JSON format
Given session coverage boost a mock service that lists empty sessions
When session coverage boost I invoke the list command with json format
Then session coverage boost the exit code is 0
Scenario: list command catches DatabaseError
Given session coverage boost a mock service that raises DatabaseError on list
When session coverage boost I invoke the list command with rich format
Then session coverage boost the exit code is 1
And session coverage boost the output contains "Database unavailable"
# ---------------------------------------------------------------
# show command
# ---------------------------------------------------------------
Scenario: show command with cost budget having a max cost
Given session coverage boost a mock service returning a session with cost budget max 10
When session coverage boost I invoke the show command
Then session coverage boost the exit code is 0
And session coverage boost the output contains "Cost Budget"
Scenario: show command with cost budget unlimited
Given session coverage boost a mock service returning a session with unlimited cost budget
When session coverage boost I invoke the show command
Then session coverage boost the exit code is 0
And session coverage boost the output contains "unlimited"
Scenario: show command with messages and linked plans in rich format
Given session coverage boost a mock service returning a session with messages and plans
When session coverage boost I invoke the show command
Then session coverage boost the exit code is 0
And session coverage boost the output contains "Recent Messages"
And session coverage boost the output contains "Linked Plans"
Scenario: show command with JSON format
Given session coverage boost a mock service returning a session with messages and plans
When session coverage boost I invoke the show command with json format
Then session coverage boost the exit code is 0
Scenario: show command catches SessionNotFoundError
Given session coverage boost a mock service that raises SessionNotFoundError on get
When session coverage boost I invoke the show command
Then session coverage boost the exit code is 1
And session coverage boost the output contains "Session not found"
Scenario: show command catches DatabaseError
Given session coverage boost a mock service that raises DatabaseError on get
When session coverage boost I invoke the show command
Then session coverage boost the exit code is 1
And session coverage boost the output contains "Database unavailable"
# ---------------------------------------------------------------
# delete command
# ---------------------------------------------------------------
Scenario: delete command succeeds with --yes flag
Given session coverage boost a mock service for delete
When session coverage boost I invoke the delete command with yes
Then session coverage boost the exit code is 0
And session coverage boost the output contains "deleted"
Scenario: delete command aborted by user
Given session coverage boost a mock service for delete
When session coverage boost I invoke the delete command without yes answering no
Then session coverage boost the output contains "Aborted"
Scenario: delete command catches SessionNotFoundError
Given session coverage boost a mock service that raises SessionNotFoundError on get
When session coverage boost I invoke the delete command with yes
Then session coverage boost the exit code is 1
And session coverage boost the output contains "Session not found"
Scenario: delete command catches DatabaseError
Given session coverage boost a mock service that raises DatabaseError on delete
When session coverage boost I invoke the delete command with yes
Then session coverage boost the exit code is 1
And session coverage boost the output contains "Database unavailable"
# ---------------------------------------------------------------
# export command
# ---------------------------------------------------------------
Scenario: export command to stdout
Given session coverage boost a mock service for export
When session coverage boost I invoke the export command to stdout
Then session coverage boost the exit code is 0
Scenario: export command to file
Given session coverage boost a mock service for export
And session coverage boost a temporary directory for export
When session coverage boost I invoke the export command to a file
Then session coverage boost the exit code is 0
And session coverage boost the output contains "exported"
Scenario: export command to existing file without force
Given session coverage boost a mock service for export
And session coverage boost a temporary directory with existing file
When session coverage boost I invoke the export command to existing file without force
Then session coverage boost the exit code is 1
And session coverage boost the output contains "File already exists"
Scenario: export command catches SessionNotFoundError
Given session coverage boost a mock service that raises SessionNotFoundError on export
When session coverage boost I invoke the export command to stdout
Then session coverage boost the exit code is 1
And session coverage boost the output contains "Session not found"
Scenario: export command catches SessionExportError
Given session coverage boost a mock service that raises SessionExportError on export
When session coverage boost I invoke the export command to stdout
Then session coverage boost the exit code is 1
And session coverage boost the output contains "Export error"
Scenario: export command catches DatabaseError
Given session coverage boost a mock service that raises DatabaseError on export
When session coverage boost I invoke the export command to stdout
Then session coverage boost the exit code is 1
And session coverage boost the output contains "Database unavailable"
# ---------------------------------------------------------------
# import command
# ---------------------------------------------------------------
Scenario: import command succeeds
Given session coverage boost a mock service for import
And session coverage boost a temporary import file with valid JSON
When session coverage boost I invoke the import command
Then session coverage boost the exit code is 0
And session coverage boost the output contains "Session Imported"
Scenario: import command with missing file
When session coverage boost I invoke the import command with missing file
Then session coverage boost the exit code is 1
And session coverage boost the output contains "File not found"
Scenario: import command with invalid JSON file
Given session coverage boost a temporary import file with invalid JSON
When session coverage boost I invoke the import command with invalid json
Then session coverage boost the exit code is 1
And session coverage boost the output contains "Invalid JSON"
Scenario: import command catches SessionImportError
Given session coverage boost a mock service that raises SessionImportError on import
And session coverage boost a temporary import file with valid JSON
When session coverage boost I invoke the import command expecting import error
Then session coverage boost the exit code is 1
And session coverage boost the output contains "Import error"
Scenario: import command catches DatabaseError
Given session coverage boost a mock service that raises DatabaseError on import
And session coverage boost a temporary import file with valid JSON
When session coverage boost I invoke the import command expecting database error
Then session coverage boost the exit code is 1
And session coverage boost the output contains "Database unavailable"
# ---------------------------------------------------------------
# tell command
# ---------------------------------------------------------------
Scenario: tell command succeeds without streaming
Given session coverage boost a mock service for tell
When session coverage boost I invoke the tell command without stream
Then session coverage boost the exit code is 0
And session coverage boost the output contains "Acknowledged"
Scenario: tell command succeeds with streaming
Given session coverage boost a mock service for tell
When session coverage boost I invoke the tell command with stream
Then session coverage boost the exit code is 0
And session coverage boost the output contains "Acknowledged"
Scenario: tell command with actor override
Given session coverage boost a mock service for tell
When session coverage boost I invoke the tell command with actor override
Then session coverage boost the exit code is 0
And session coverage boost the output contains "openai/gpt-4"
Scenario: tell command catches SessionNotFoundError
Given session coverage boost a mock service that raises SessionNotFoundError on append
When session coverage boost I invoke the tell command without stream
Then session coverage boost the exit code is 1
And session coverage boost the output contains "Session not found"
Scenario: tell command catches DatabaseError
Given session coverage boost a mock service that raises DatabaseError on append
When session coverage boost I invoke the tell command without stream
Then session coverage boost the exit code is 1
And session coverage boost the output contains "Database unavailable"
# ---------------------------------------------------------------
# show command with long message content truncation
# ---------------------------------------------------------------
Scenario: show command truncates long message content
Given session coverage boost a mock service returning a session with a long message
When session coverage boost I invoke the show command
Then session coverage boost the exit code is 0
And session coverage boost the output contains truncated message indicator