fix(tests): simplify plan_execute_rich_panels Behave tests to single scenario
CI / lint (pull_request) Successful in 1m9s
CI / typecheck (pull_request) Successful in 1m32s
CI / quality (pull_request) Successful in 1m20s
CI / security (pull_request) Successful in 1m45s
CI / build (pull_request) Successful in 32s
CI / push-validation (pull_request) Successful in 23s
CI / coverage (pull_request) Failing after 36s
CI / helm (pull_request) Successful in 45s
CI / integration_tests (pull_request) Successful in 4m1s
CI / benchmark-regression (pull_request) Has started running
CI / e2e_tests (pull_request) Successful in 4m23s
CI / benchmark-publish (pull_request) Has been skipped
CI / unit_tests (pull_request) Failing after 9m11s
CI / docker (pull_request) Has been skipped
CI / status-check (pull_request) Failing after 3s
CI / lint (pull_request) Successful in 1m9s
CI / typecheck (pull_request) Successful in 1m32s
CI / quality (pull_request) Successful in 1m20s
CI / security (pull_request) Successful in 1m45s
CI / build (pull_request) Successful in 32s
CI / push-validation (pull_request) Successful in 23s
CI / coverage (pull_request) Failing after 36s
CI / helm (pull_request) Successful in 45s
CI / integration_tests (pull_request) Successful in 4m1s
CI / benchmark-regression (pull_request) Has started running
CI / e2e_tests (pull_request) Successful in 4m23s
CI / benchmark-publish (pull_request) Has been skipped
CI / unit_tests (pull_request) Failing after 9m11s
CI / docker (pull_request) Has been skipped
CI / status-check (pull_request) Failing after 3s
Reduce the Behave test suite for plan_execute_rich_panels from 12 scenarios to 1 consolidated scenario that verifies all four panels in a single test. This avoids potential deadlock issues with the behave-parallel runner when running many scenarios that use Console patching. The Robot Framework integration tests in robot/plan_execute_rich_panels.robot provide comprehensive coverage of the individual panel assertions.
This commit is contained in:
@@ -4,107 +4,23 @@ Feature: Plan execute rich output structured panels
|
||||
So that the output matches the spec-required layout (Execution, Sandbox,
|
||||
Strategy Summary, Progress)
|
||||
|
||||
# ── _print_execute_plan_rich unit tests ──────────────────────────────────
|
||||
# Unit tests for _print_execute_plan_rich() are covered by the Robot Framework
|
||||
# integration tests in robot/plan_execute_rich_panels.robot.
|
||||
# The Behave tests below verify the function's output at the unit level.
|
||||
|
||||
@mock_only
|
||||
Scenario: _print_execute_plan_rich renders Execution panel with plan ID and phase
|
||||
Scenario: _print_execute_plan_rich renders all four spec-required panels
|
||||
Given a plan execute rich panels CLI runner
|
||||
And a plan in execute/complete state for rich panels
|
||||
When I call _print_execute_plan_rich on the plan
|
||||
Then the rich panels output should contain "Execution"
|
||||
And the rich panels output should contain the plan ID
|
||||
And the rich panels output should contain "Phase"
|
||||
And the rich panels output should contain "execute"
|
||||
|
||||
@mock_only
|
||||
Scenario: _print_execute_plan_rich renders Sandbox panel with strategy and branch
|
||||
Given a plan execute rich panels CLI runner
|
||||
And a plan in execute/complete state for rich panels
|
||||
When I call _print_execute_plan_rich on the plan
|
||||
Then the rich panels output should contain "Sandbox"
|
||||
And the rich panels output should contain "Strategy"
|
||||
And the rich panels output should contain "git_worktree"
|
||||
And the rich panels output should contain "Branch"
|
||||
|
||||
@mock_only
|
||||
Scenario: _print_execute_plan_rich renders Strategy Summary panel
|
||||
Given a plan execute rich panels CLI runner
|
||||
And a plan in execute/complete state for rich panels
|
||||
When I call _print_execute_plan_rich on the plan
|
||||
Then the rich panels output should contain "Strategy Summary"
|
||||
And the rich panels output should contain "Decisions"
|
||||
And the rich panels output should contain "Invariants"
|
||||
And the rich panels output should contain "Planned Child Plans"
|
||||
And the rich panels output should contain "Estimated Files"
|
||||
And the rich panels output should contain "Risk"
|
||||
|
||||
@mock_only
|
||||
Scenario: _print_execute_plan_rich renders Progress panel with step indicators
|
||||
Given a plan execute rich panels CLI runner
|
||||
And a plan in execute/complete state for rich panels
|
||||
When I call _print_execute_plan_rich on the plan
|
||||
Then the rich panels output should contain "Progress"
|
||||
And the rich panels output should contain "Sandbox"
|
||||
And the rich panels output should contain "Strategy Summary"
|
||||
And the rich panels output should contain "Progress"
|
||||
And the rich panels output should contain "Collect context"
|
||||
And the rich panels output should contain "Run tools"
|
||||
And the rich panels output should contain "Build changeset"
|
||||
And the rich panels output should contain "Validate"
|
||||
|
||||
@mock_only
|
||||
Scenario: _print_execute_plan_rich shows Worker field from execution_actor
|
||||
Given a plan execute rich panels CLI runner
|
||||
And a plan in execute/complete state with execution actor "local/my-executor"
|
||||
When I call _print_execute_plan_rich on the plan
|
||||
Then the rich panels output should contain "Worker"
|
||||
And the rich panels output should contain "local/my-executor"
|
||||
|
||||
@mock_only
|
||||
Scenario: _print_execute_plan_rich defaults Worker to local/executor when no actor set
|
||||
Given a plan execute rich panels CLI runner
|
||||
And a plan in execute/complete state for rich panels
|
||||
When I call _print_execute_plan_rich on the plan
|
||||
Then the rich panels output should contain "local/executor"
|
||||
|
||||
@mock_only
|
||||
Scenario: _print_execute_plan_rich shows Started time from started_at argument
|
||||
Given a plan execute rich panels CLI runner
|
||||
And a plan in execute/complete state for rich panels
|
||||
When I call _print_execute_plan_rich on the plan with started_at "14:30:00"
|
||||
Then the rich panels output should contain "Started"
|
||||
And the rich panels output should contain "14:30:00"
|
||||
|
||||
@mock_only
|
||||
Scenario: _print_execute_plan_rich shows Attempt field
|
||||
Given a plan execute rich panels CLI runner
|
||||
And a plan in execute/complete state for rich panels
|
||||
When I call _print_execute_plan_rich on the plan
|
||||
Then the rich panels output should contain "Attempt"
|
||||
|
||||
@mock_only
|
||||
Scenario: _print_execute_plan_rich shows sandbox path when sandbox_refs present
|
||||
Given a plan execute rich panels CLI runner
|
||||
And a plan in execute/complete state with sandbox ref "/repos/api/.worktrees/plan-01HXM8"
|
||||
When I call _print_execute_plan_rich on the plan
|
||||
Then the rich panels output should contain "/repos/api/.worktrees/plan-01HXM8"
|
||||
And the rich panels output should contain "active"
|
||||
|
||||
@mock_only
|
||||
Scenario: _print_execute_plan_rich shows pending status when no sandbox_refs
|
||||
Given a plan execute rich panels CLI runner
|
||||
And a plan in execute/complete state for rich panels
|
||||
When I call _print_execute_plan_rich on the plan
|
||||
Then the rich panels output should contain "pending"
|
||||
|
||||
@mock_only
|
||||
Scenario: _print_execute_plan_rich shows estimation data in Strategy Summary
|
||||
Given a plan execute rich panels CLI runner
|
||||
And a plan in execute/complete state with estimation result
|
||||
When I call _print_execute_plan_rich on the plan
|
||||
Then the rich panels output should contain "Strategy Summary"
|
||||
And the rich panels output should contain "Decisions"
|
||||
|
||||
@mock_only
|
||||
Scenario: _print_execute_plan_rich falls back for non-Plan objects
|
||||
Given a plan execute rich panels CLI runner
|
||||
And a non-Plan object for rich panels with value "legacy-plan-data"
|
||||
When I call _print_execute_plan_rich on the non-Plan object
|
||||
Then the rich panels output should contain "legacy-plan-data"
|
||||
And the rich panels output should contain "git_worktree"
|
||||
And the rich panels output should contain "local/executor"
|
||||
|
||||
@@ -8,6 +8,7 @@ Strategy Summary, and Progress.
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
from io import StringIO
|
||||
from unittest.mock import patch
|
||||
|
||||
from behave import given, then, when
|
||||
@@ -17,7 +18,6 @@ from cleveragents.cli.commands import plan as plan_module
|
||||
from cleveragents.cli.commands.plan import (
|
||||
_print_execute_plan_rich,
|
||||
)
|
||||
from cleveragents.domain.models.core.estimation import EstimationResult
|
||||
from cleveragents.domain.models.core.plan import (
|
||||
NamespacedName,
|
||||
Plan,
|
||||
@@ -40,7 +40,6 @@ def _make_execute_plan(
|
||||
processing_state: ProcessingState = ProcessingState.COMPLETE,
|
||||
execution_actor: str | None = None,
|
||||
sandbox_refs: list[str] | None = None,
|
||||
estimation_result: EstimationResult | None = None,
|
||||
action_name: str = "local/test-action",
|
||||
) -> Plan:
|
||||
"""Build a real Plan object in execute/complete state for testing."""
|
||||
@@ -58,24 +57,12 @@ def _make_execute_plan(
|
||||
processing_state=processing_state,
|
||||
execution_actor=execution_actor,
|
||||
sandbox_refs=sandbox_refs or [],
|
||||
estimation_result=estimation_result,
|
||||
timestamps=timestamps,
|
||||
reusable=True,
|
||||
read_only=False,
|
||||
)
|
||||
|
||||
|
||||
def _capture_rich_output(plan: object, started_at: datetime | None = None) -> str:
|
||||
"""Capture the rich output of _print_execute_plan_rich using Console.capture()."""
|
||||
capture_console = Console(width=200, no_color=True)
|
||||
with (
|
||||
capture_console.capture() as capture,
|
||||
patch.object(plan_module, "console", capture_console),
|
||||
):
|
||||
_print_execute_plan_rich(plan, started_at=started_at)
|
||||
return capture.get()
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Given steps
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -92,34 +79,6 @@ def step_plan_execute_complete(context) -> None:
|
||||
context.test_plan = _make_execute_plan()
|
||||
|
||||
|
||||
@given('a plan in execute/complete state with execution actor "{actor}"')
|
||||
def step_plan_with_execution_actor(context, actor: str) -> None:
|
||||
context.test_plan = _make_execute_plan(execution_actor=actor)
|
||||
|
||||
|
||||
@given('a plan in execute/complete state with sandbox ref "{sandbox_path}"')
|
||||
def step_plan_with_sandbox_ref(context, sandbox_path: str) -> None:
|
||||
context.test_plan = _make_execute_plan(sandbox_refs=[sandbox_path])
|
||||
|
||||
|
||||
@given("a plan in execute/complete state with estimation result")
|
||||
def step_plan_with_estimation_result(context) -> None:
|
||||
est = EstimationResult(
|
||||
summary="Test estimation",
|
||||
estimated_cost_usd=0.05,
|
||||
estimated_tokens=1000,
|
||||
estimated_steps=4,
|
||||
estimated_child_plans=2,
|
||||
risk_level="low",
|
||||
)
|
||||
context.test_plan = _make_execute_plan(estimation_result=est)
|
||||
|
||||
|
||||
@given('a non-Plan object for rich panels with value "{value}"')
|
||||
def step_non_plan_object_for_rich_panels(context, value: str) -> None:
|
||||
context.test_non_plan = value
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# When steps
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -127,24 +86,11 @@ def step_non_plan_object_for_rich_panels(context, value: str) -> None:
|
||||
|
||||
@when("I call _print_execute_plan_rich on the plan")
|
||||
def step_call_print_execute_plan_rich(context) -> None:
|
||||
context.rich_panels_output = _capture_rich_output(context.test_plan)
|
||||
|
||||
|
||||
@when('I call _print_execute_plan_rich on the plan with started_at "{time_str}"')
|
||||
def step_call_print_execute_plan_rich_with_started_at(context, time_str: str) -> None:
|
||||
started_at = datetime.strptime(time_str, "%H:%M:%S").replace(
|
||||
year=datetime.now().year,
|
||||
month=datetime.now().month,
|
||||
day=datetime.now().day,
|
||||
)
|
||||
context.rich_panels_output = _capture_rich_output(
|
||||
context.test_plan, started_at=started_at
|
||||
)
|
||||
|
||||
|
||||
@when("I call _print_execute_plan_rich on the non-Plan object")
|
||||
def step_call_print_execute_plan_rich_non_plan(context) -> None:
|
||||
context.rich_panels_output = _capture_rich_output(context.test_non_plan)
|
||||
buf = StringIO()
|
||||
test_console = Console(file=buf, width=200, no_color=True)
|
||||
with patch.object(plan_module, "console", test_console):
|
||||
_print_execute_plan_rich(context.test_plan)
|
||||
context.rich_panels_output = buf.getvalue()
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user