Skip to content

Public dotflow.testing package with pytest fixtures #295

Description

@FernandoCelmer

Labels: enhancement, good first issue

Context

There is no public test harness for consumers. Anyone testing a workflow must either:

  • Mock StorageDefault, ServerDefault, MetricsDefault,
    LogDefault by hand.
  • Or rely on the real defaults, which is fine in unit tests but
    surfaces friction when one of them does I/O.

Concept

Expose a dotflow.testing module with ready-made fixtures. Consumers import them in their conftest.py with one line.

Proposed module

# dotflow/testing/__init__.py
import pytest
from dotflow import DotFlow, Config
from dotflow.providers.storage_default import StorageDefault

@pytest.fixture
def dotflow_storage():
    """Fresh in-memory storage for each test."""
    return StorageDefault()

@pytest.fixture
def dotflow_config(dotflow_storage):
    return Config(storage=dotflow_storage)

@pytest.fixture
def dotflow_workflow(dotflow_config):
    """A clean DotFlow with in-memory storage and no managed server."""
    return DotFlow(config=dotflow_config)

Usage in consumer code:

# user's conftest.py
from dotflow.testing import (
    dotflow_storage,
    dotflow_config,
    dotflow_workflow,
)

# user's test
def test_etl(dotflow_workflow, dotflow_storage):
    dotflow_workflow.task.add(step=extract)
    dotflow_workflow.task.add(step=transform)
    dotflow_workflow.start()
    assert dotflow_storage.get(...) is not None

Acceptance criteria

  • dotflow.testing importable
  • Fixtures dotflow_storage, dotflow_config,
    dotflow_workflow
  • Documentation page "Testing your workflows" with usage example
  • No pytest runtime dependency on the main library install
    (move to extras_require={'testing': ['pytest']})

Future expansions

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions