fix: resolve ruff lint errors in Phase 2 code
- Move intent imports to TYPE_CHECKING block in graph.py (TC001) - Rename test classes to CapWords convention (N801) - Fix line length violations across test files (E501) - Auto-fix import sorting (I001)
This commit is contained in:
@@ -90,7 +90,7 @@ def _agent(name: str, desc: str, perm: str = "read") -> AgentConfig:
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
@pytest.mark.integration
|
||||
class TestCheckpoint1_OrderQueryRouting:
|
||||
class TestCheckpoint1OrderQueryRouting:
|
||||
"""Verify intent classifier routes order queries to order_lookup."""
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -161,7 +161,7 @@ class TestCheckpoint1_OrderQueryRouting:
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
@pytest.mark.integration
|
||||
class TestCheckpoint2_MultiIntentSequential:
|
||||
class TestCheckpoint2MultiIntentSequential:
|
||||
"""Verify multi-intent classified and hint injected for sequential execution."""
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -235,7 +235,7 @@ class TestCheckpoint2_MultiIntentSequential:
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
@pytest.mark.integration
|
||||
class TestCheckpoint3_AmbiguousClarification:
|
||||
class TestCheckpoint3AmbiguousClarification:
|
||||
"""Verify ambiguous messages trigger clarification prompt."""
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -263,7 +263,9 @@ class TestCheckpoint3_AmbiguousClarification:
|
||||
mock_classifier.classify = AsyncMock(return_value=ClassificationResult(
|
||||
intents=(),
|
||||
is_ambiguous=True,
|
||||
clarification_question="Could you please provide more details about what you need help with?",
|
||||
clarification_question=(
|
||||
"Could you please provide more details about what you need help with?"
|
||||
),
|
||||
))
|
||||
graph.intent_classifier = mock_classifier
|
||||
mock_registry = MagicMock()
|
||||
@@ -294,7 +296,7 @@ class TestCheckpoint3_AmbiguousClarification:
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
@pytest.mark.integration
|
||||
class TestCheckpoint4_InterruptTTLAutoCancel:
|
||||
class TestCheckpoint4InterruptTTLAutoCancel:
|
||||
"""Verify interrupt TTL expiration triggers auto-cancel and retry prompt."""
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -361,7 +363,7 @@ class TestCheckpoint4_InterruptTTLAutoCancel:
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
@pytest.mark.integration
|
||||
class TestCheckpoint5_WebhookEscalation:
|
||||
class TestCheckpoint5WebhookEscalation:
|
||||
"""Verify webhook escalation sends POST and retries on failure."""
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -442,7 +444,7 @@ class TestCheckpoint5_WebhookEscalation:
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
@pytest.mark.integration
|
||||
class TestCheckpoint6_EcommerceTemplate:
|
||||
class TestCheckpoint6EcommerceTemplate:
|
||||
"""Verify e-commerce template loads with correct agents."""
|
||||
|
||||
def test_ecommerce_template_loads_4_agents(self) -> None:
|
||||
|
||||
@@ -24,7 +24,6 @@ from app.registry import AgentConfig
|
||||
from app.session_manager import SessionManager
|
||||
from app.ws_handler import dispatch_message
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Helpers
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -78,10 +77,22 @@ def _state(*, interrupt: bool = False, data: dict | None = None):
|
||||
|
||||
|
||||
AGENTS = (
|
||||
AgentConfig(name="order_lookup", description="Looks up orders", permission="read", tools=["get_order_status", "get_tracking_info"]),
|
||||
AgentConfig(name="order_actions", description="Modifies orders", permission="write", tools=["cancel_order"]),
|
||||
AgentConfig(name="discount", description="Applies discounts", permission="write", tools=["apply_discount", "generate_coupon"]),
|
||||
AgentConfig(name="fallback", description="Handles unclear requests", permission="read", tools=["fallback_respond"]),
|
||||
AgentConfig(
|
||||
name="order_lookup", description="Looks up orders",
|
||||
permission="read", tools=["get_order_status", "get_tracking_info"],
|
||||
),
|
||||
AgentConfig(
|
||||
name="order_actions", description="Modifies orders",
|
||||
permission="write", tools=["cancel_order"],
|
||||
),
|
||||
AgentConfig(
|
||||
name="discount", description="Applies discounts",
|
||||
permission="write", tools=["apply_discount", "generate_coupon"],
|
||||
),
|
||||
AgentConfig(
|
||||
name="fallback", description="Handles unclear requests",
|
||||
permission="read", tools=["fallback_respond"],
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -136,7 +147,9 @@ class TestSingleIntentRouting:
|
||||
@pytest.mark.asyncio
|
||||
async def test_routes_to_order_lookup(self) -> None:
|
||||
result = ClassificationResult(
|
||||
intents=(IntentTarget(agent_name="order_lookup", confidence=0.95, reasoning="status query"),),
|
||||
intents=(IntentTarget(
|
||||
agent_name="order_lookup", confidence=0.95, reasoning="status query",
|
||||
),),
|
||||
)
|
||||
graph = _make_graph(result, [
|
||||
_tool_chunk("get_order_status", {"order_id": "1042"}, "order_lookup"),
|
||||
|
||||
@@ -19,7 +19,6 @@ from app.interrupt_manager import InterruptManager
|
||||
from app.session_manager import SessionManager
|
||||
from app.ws_handler import dispatch_message
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Helpers
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -182,7 +181,8 @@ class TestWebSocketInterruptApproval:
|
||||
@pytest.mark.asyncio
|
||||
async def test_interrupt_then_approve(self) -> None:
|
||||
st_int = _state(interrupt=True, data={"action": "cancel_order", "order_id": "1042"})
|
||||
g = _graph(chunks=[], st=st_int, resume_chunks=[_chunk("Order 1042 cancelled.", "order_actions")])
|
||||
resume = [_chunk("Order 1042 cancelled.", "order_actions")]
|
||||
g = _graph(chunks=[], st=st_int, resume_chunks=resume)
|
||||
g_, sm, im, cb, ws = _setup(graph=g)
|
||||
|
||||
# Send message -> triggers interrupt
|
||||
@@ -209,7 +209,8 @@ class TestWebSocketInterruptApproval:
|
||||
@pytest.mark.asyncio
|
||||
async def test_interrupt_then_reject(self) -> None:
|
||||
st_int = _state(interrupt=True)
|
||||
g = _graph(chunks=[], st=st_int, resume_chunks=[_chunk("Order remains active.", "order_actions")])
|
||||
resume = [_chunk("Order remains active.", "order_actions")]
|
||||
g = _graph(chunks=[], st=st_int, resume_chunks=resume)
|
||||
g_, sm, im, cb, ws = _setup(graph=g)
|
||||
|
||||
await _send(ws, g_, sm, im, cb, content="Cancel order 1042")
|
||||
|
||||
Reference in New Issue
Block a user