| """ |
| Workflow test data factories. |
| |
| Provides factory functions for creating test workflow data with minimal boilerplate. |
| |
| Note: These are placeholder factories. Actual model imports depend on workflow models |
| being defined in core.models.py. Use these as templates for your specific workflow models. |
| """ |
|
|
| from datetime import datetime |
| from typing import Optional, Dict, Any, List |
| from sqlalchemy.orm import Session |
|
|
|
|
| def create_test_workflow( |
| db_session: Session, |
| name: str = "TestWorkflow", |
| status: str = "active", |
| version: int = 1, |
| **kwargs |
| ) -> Any: |
| """Factory function to create test workflows with defaults. |
| |
| Note: This is a template. Implement based on your actual Workflow model. |
| |
| Args: |
| db_session: Database session |
| name: Workflow name |
| status: Workflow status (active, draft, archived) |
| version: Workflow version |
| **kwargs: Additional workflow fields |
| |
| Returns: |
| Created workflow instance |
| |
| Example: |
| workflow = create_test_workflow(db_session, name="MyWorkflow") |
| """ |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| |
| return {"id": "test_workflow", "name": name, "status": status, "version": version} |
|
|
|
|
| def create_workflow_execution( |
| db_session: Session, |
| workflow_id: str, |
| status: str = "pending", |
| **kwargs |
| ) -> Any: |
| """Factory function to create test workflow executions. |
| |
| Note: This is a template. Implement based on your actual WorkflowExecution model. |
| |
| Args: |
| db_session: Database session |
| workflow_id: Parent workflow ID |
| status: Execution status (pending, running, completed, failed) |
| **kwargs: Additional execution fields |
| |
| Returns: |
| Created workflow execution instance |
| """ |
| |
| return {"workflow_id": workflow_id, "status": status} |
|
|
|
|
| def create_workflow_step( |
| db_session: Session, |
| execution_id: str, |
| step_name: str = "test_step", |
| status: str = "pending", |
| **kwargs |
| ) -> Any: |
| """Factory function to create test workflow steps. |
| |
| Note: This is a template. Implement based on your actual WorkflowStep model. |
| |
| Args: |
| db_session: Database session |
| execution_id: Parent execution ID |
| step_name: Step name |
| status: Step status (pending, running, completed, failed) |
| **kwargs: Additional step fields |
| |
| Returns: |
| Created workflow step instance |
| """ |
| |
| return {"execution_id": execution_id, "step_name": step_name, "status": status} |
|
|
|
|
| def create_workflow_with_steps( |
| db_session: Session, |
| workflow_name: str = "MultiStepWorkflow", |
| step_count: int = 3 |
| ) -> tuple: |
| """Create a complete workflow with execution and steps. |
| |
| Note: This is a template. Implement based on your actual workflow models. |
| |
| Args: |
| db_session: Database session |
| workflow_name: Workflow name |
| step_count: Number of steps to create |
| |
| Returns: |
| Tuple of (workflow, execution, steps) |
| """ |
| workflow = create_test_workflow(db_session, name=workflow_name) |
| execution = create_workflow_execution(db_session, workflow_id=workflow["id"]) |
| steps = [create_workflow_step(db_session, execution_id=execution["id"], step_name=f"step_{i+1}") for i in range(step_count)] |
| return workflow, execution, steps |
|
|