fix(feature/tests): Add missing step handlers and fix TDD tags for PlanGenerationGraph validate tests

- Added Given step handler 'I have a langgraph PlanGenerationGraph instance'
  to create a PlanGenerationGraph with FakeListLLM in the test setup.
- Added Then step handler 'the langgraph validation status should be "{status}"'
  to assert PASS/FAIL results from _validate().
- Fixed TDD tag format: replaced '@tdd_issue @tdd_issue_10746' with '@tdd_issue_10746'
  per project convention (single tdd tag, not two).

These changes resolve all three review blocking issues for PR #10867:
1. Missing Given step handler causing test execution failures.
2. Missing Then step handler causing Behave StepDefinitionNotFoundError.
3. TDD tag format violation preventing CI from properly tagging tests.

The core code fix (removing length-based bypass in _validate) was already
correctly implemented and does not need changes.

ISSUES CLOSED: #10867
This commit is contained in:
2026-05-11 02:13:57 +00:00
committed by drew
parent 0ee759c2bd
commit 4f09dbfee2
2 changed files with 33 additions and 6 deletions
@@ -1,11 +1,31 @@
"""Additional Behave steps for TDD validation scenarios for PlanGenerationGraph."""
from __future__ import annotations
from behave import when
from typing import Any
from behave import given, then, when
from langchain_community.llms import FakeListLLM
from cleveragents.agents.plan_generation import PlanGenerationGraph
from cleveragents.domain.models.core import Change, OperationType
def _test_llm() -> FakeListLLM:
"""Create a FakeListLLM for test purposes."""
return FakeListLLM(
responses=[
"Requirements: Add error handling with try-except blocks",
"Generated code with proper error handling implementation",
"Validation passed: Code follows best practices",
]
)
@given("I have a langgraph PlanGenerationGraph instance")
def step_have_langgraph_graph_instance(context: Any) -> None:
"""Create a PlanGenerationGraph instance with a test LLM."""
context.graph = PlanGenerationGraph(llm=_test_llm())
@when("I execute the langgraph validate node with generated code:")
def step_execute_langgraph_validate_with_code(context: Any) -> None:
"""Execute validate node with provided generated code in the step docstring.
@@ -33,3 +53,10 @@ def step_execute_langgraph_validate_with_code(context: Any) -> None:
)
state = {"generated_changes": [change]}
context.node_result = context.graph._validate(state)
@then("the langgraph validation status should be \"{status}\"")
def step_validation_status(context: Any, status: str) -> None:
"""Verify the validation result has the expected status."""
result = context.node_result["validation_result"]
assert result["status"] == status.upper()
@@ -3,7 +3,7 @@ Feature: TDD — PlanGenerationGraph validation logic
I want the PlanGenerationGraph._validate() logic to respect explicit LLM FAIL responses
So that generated code is rejected when the LLM indicates failure, regardless of code length
@tdd_issue @tdd_issue_10746
@tdd_issue_10746
Scenario: FAIL response is respected for code longer than 10 characters
Given I have a langgraph PlanGenerationGraph instance
When I execute the langgraph validate node with generated code:
@@ -12,7 +12,7 @@ Feature: TDD — PlanGenerationGraph validation logic
"""
Then the langgraph validation status should be "FAIL"
@tdd_issue @tdd_issue_10746
@tdd_issue_10746
Scenario: PASS response is accepted when no FAIL present
Given I have a langgraph PlanGenerationGraph instance
When I execute the langgraph validate node with generated code:
@@ -21,7 +21,7 @@ Feature: TDD — PlanGenerationGraph validation logic
"""
Then the langgraph validation status should be "PASS"
@tdd_issue @tdd_issue_10746
@tdd_issue_10746
Scenario: Mixed PASS and FAIL prefers FAIL
Given I have a langgraph PlanGenerationGraph instance
When I execute the langgraph validate node with generated code:
@@ -31,7 +31,7 @@ Feature: TDD — PlanGenerationGraph validation logic
"""
Then the langgraph validation status should be "FAIL"
@tdd_issue @tdd_issue_10746
@tdd_issue_10746
Scenario: No explicit PASS or FAIL and code length > 10 should fail
Given I have a langgraph PlanGenerationGraph instance
When I execute the langgraph validate node with generated code:
@@ -41,7 +41,7 @@ Feature: TDD — PlanGenerationGraph validation logic
"""
Then the langgraph validation status should be "FAIL"
@tdd_issue @tdd_issue_10746
@tdd_issue_10746
Scenario: PASS keyword in mixed-case is accepted (case-insensitive)
Given I have a langgraph PlanGenerationGraph instance
When I execute the langgraph validate node with generated code: