fix(i-e): BUG-099 geschlossen — tote workstream-Tests entfernt, Import-Test korrigiert
app.ai.agent_workstream und app.workflows.workstream sind geloescht (Phase-2-Roadmap); lazy Imports brachen zur Laufzeit. Chirurgische Entfernung: TestWorkstream-Klasse phase_f (120 Zeilen), TestWorkflowWorkstream + G-WORK-Sektion phase_g (73 Zeilen), test_workstream_to_task_transition spike_i. test_all_modules_importable auf existierende Exporte korrigiert (fetch_source_content->get_available_sources, auto_create_relationships->filter_high_confidence); alle anderen Module via importlib-Check verifiziert OK. ruff: 21 Findings auto-gefixt, 1 F841-Vorbestand belassen. Beweis: phase_f+phase_g+spike_i 88/88 passed in 19.16s; to_workstream_block()-Tests bleiben valide (existiert in app.ai.knowledge_sources).
This commit is contained in:
@@ -5,7 +5,6 @@ All tests use mocks — no real DB/LLM/Redis/HTTP needed.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import uuid
|
||||
from datetime import UTC, datetime, timedelta
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
@@ -14,12 +13,11 @@ import pytest
|
||||
|
||||
from app.workflows.step_handlers import (
|
||||
StepResult,
|
||||
get_step_handler,
|
||||
get_available_step_types,
|
||||
_is_url_safe,
|
||||
get_available_step_types,
|
||||
get_step_handler,
|
||||
)
|
||||
|
||||
|
||||
# ─── Step Handler Registry ────────────────────────────────────────────────────
|
||||
|
||||
|
||||
@@ -308,7 +306,6 @@ class TestWorkflowEngineResume:
|
||||
async def test_find_resumable_workflows_query(self):
|
||||
"""find_resumable_workflows queries for waiting instances with passed resume_at."""
|
||||
from app.workflows.engine import find_resumable_workflows
|
||||
from app.models.workflow import WorkflowInstance
|
||||
|
||||
db = MagicMock()
|
||||
mock_result = MagicMock()
|
||||
@@ -335,9 +332,10 @@ class TestWorkflowSchema:
|
||||
|
||||
def test_step_schema_rejects_unknown_type(self):
|
||||
"""WorkflowStep schema rejects unknown step types."""
|
||||
from app.schemas.workflow import WorkflowStep
|
||||
from pydantic import ValidationError
|
||||
|
||||
from app.schemas.workflow import WorkflowStep
|
||||
|
||||
with pytest.raises(ValidationError):
|
||||
WorkflowStep(name="Bad", type="unknown_type", config={})
|
||||
|
||||
@@ -464,75 +462,3 @@ class TestDecisionGuard:
|
||||
assert "send_email" in result["reason"]
|
||||
|
||||
|
||||
# ─── G-WORK: Workflow Workstream ─────────────────────────────────────────────
|
||||
|
||||
|
||||
class TestWorkflowWorkstream:
|
||||
"""Test the workflow workstream integration (G-WORK)."""
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_post_workflow_status_fallback_to_notification(self):
|
||||
"""post_workflow_status falls back to system notification when CommContract unavailable."""
|
||||
from app.workflows.workstream import post_workflow_status
|
||||
|
||||
with patch("app.core.notifications.post_system_message", new_callable=AsyncMock):
|
||||
result = await post_workflow_status(
|
||||
db=MagicMock(),
|
||||
tenant_id=uuid.uuid4(),
|
||||
instance_id=uuid.uuid4(),
|
||||
workflow_name="Test Workflow",
|
||||
status="in_progress",
|
||||
user_id=uuid.uuid4(),
|
||||
)
|
||||
# Should return None (fallback) but not crash
|
||||
assert result is None
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_post_workflow_error_fallback_to_notification(self):
|
||||
"""post_workflow_error falls back to system notification."""
|
||||
from app.workflows.workstream import post_workflow_error
|
||||
|
||||
with patch("app.core.notifications.post_system_message", new_callable=AsyncMock):
|
||||
result = await post_workflow_error(
|
||||
db=MagicMock(),
|
||||
tenant_id=uuid.uuid4(),
|
||||
instance_id=uuid.uuid4(),
|
||||
workflow_name="Test Workflow",
|
||||
error="Something went wrong",
|
||||
user_id=uuid.uuid4(),
|
||||
)
|
||||
assert result is None
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_post_workflow_completed_fallback_to_notification(self):
|
||||
"""post_workflow_completed falls back to system notification."""
|
||||
from app.workflows.workstream import post_workflow_completed
|
||||
|
||||
with patch("app.core.notifications.post_system_message", new_callable=AsyncMock):
|
||||
result = await post_workflow_completed(
|
||||
db=MagicMock(),
|
||||
tenant_id=uuid.uuid4(),
|
||||
instance_id=uuid.uuid4(),
|
||||
workflow_name="Test Workflow",
|
||||
result={"output": "done"},
|
||||
user_id=uuid.uuid4(),
|
||||
)
|
||||
assert result is None
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_post_workflow_handoff_fallback_to_notification(self):
|
||||
"""post_workflow_handoff falls back to system notification."""
|
||||
from app.workflows.workstream import post_workflow_handoff
|
||||
|
||||
with patch("app.core.notifications.post_system_message", new_callable=AsyncMock):
|
||||
result = await post_workflow_handoff(
|
||||
db=MagicMock(),
|
||||
tenant_id=uuid.uuid4(),
|
||||
instance_id=uuid.uuid4(),
|
||||
workflow_name="Test Workflow",
|
||||
handoff_type="review_needed",
|
||||
assignee_id=uuid.uuid4(),
|
||||
description="Please review",
|
||||
user_id=uuid.uuid4(),
|
||||
)
|
||||
assert result is None
|
||||
|
||||
Reference in New Issue
Block a user