Skip to content

feat(tests): replace hardcoded YAML strings with factory fixtures#259

Merged
mvillmow merged 2 commits into
mainfrom
149-auto-impl
Jun 29, 2026
Merged

feat(tests): replace hardcoded YAML strings with factory fixtures#259
mvillmow merged 2 commits into
mainfrom
149-auto-impl

Conversation

@mvillmow

@mvillmow mvillmow commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Replace hardcoded YAML string literals and inline workflow dicts with a single set of typed factory functions in tests/conftest.py. Each test now calls a factory with only the fields it cares about; defaults come from one place.

Before: Changes to the schema required updating 5 hardcoded YAML strings across two test files.
After: Changes require editing one file (conftest.py).

Closes #149

Changes

  • Create tests/conftest.py:

    • make_agent_dict, make_task_dict, make_team_dict — dict builders
    • make_workflow_dict — complete workflow dict builder
    • make_workflow_yaml, make_workflow_spec — typed views of the workflow
    • make_two_task_dep_dict — canonical two-agent dependency test fixture
    • workflow_dict_factory, workflow_spec_factory, workflow_file_factory — pytest fixtures
  • Update tests/test_models.py:

    • Remove MINIMAL_WORKFLOW_YAML and TWO_TASK_DEP_YAML
    • Remove import yaml
    • Update all 14 tests to use workflow_spec_factory or workflow_dict_factory
    • Migrate test_cycle_raises inline dict to use workflow_dict_factory()
  • Update tests/test_cli.py:

    • Remove _VALID_WORKFLOW_YAML and _INVALID_WORKFLOW_YAML_MISSING_NAME
    • Update valid_workflow_file to delegate to workflow_file_factory
    • Update invalid_workflow_file to use make_workflow_dict() then delete the name key
    • No changes to test bodies

Test Results

  • ✓ All 20 tests in test_models.py + test_cli.py pass
  • ✓ All 48 tests in full suite pass
  • ✓ No hardcoded YAML constants remain (grep verified)
  • ✓ No inline workflow-shaped dicts remain (grep verified)
  • ✓ Lint: ruff check passes

🤖 Generated with Claude Code

@mvillmow mvillmow left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — hardcoded YAML constants replaced by typed factories in conftest.py; all test names/signatures preserved, factory dicts satisfy extra=forbid, match strings align with validators. No defects in changed lines.

Addresses #149: consolidate workflow fixture creation from 5 hardcoded
YAML strings scattered across test_models.py and test_cli.py into a
single set of typed factory functions in conftest.py. Each test now calls
the factory with only the fields it cares about; defaults live in one place.

This makes schema evolution resilient: a new required field on AgentSpec
now requires editing conftest.py only, rather than updating every fixture
that constructs an agent.

Changes:
- Create tests/conftest.py with make_agent_dict, make_task_dict,
  make_team_dict, make_workflow_dict, make_workflow_yaml, make_workflow_spec,
  and make_two_task_dep_dict factory functions
- Expose workflow_dict_factory, workflow_spec_factory, and workflow_file_factory
  as pytest fixtures for test consumption
- Remove MINIMAL_WORKFLOW_YAML, TWO_TASK_DEP_YAML from test_models.py
- Remove _VALID_WORKFLOW_YAML, _INVALID_WORKFLOW_YAML_MISSING_NAME from test_cli.py
- Update all tests to use factories instead of YAML strings
- Migrate test_cycle_raises to use factory scaffolding
- Update imports to use collections.abc.Callable (Python 3.9+)

All 20 tests in test_models.py and test_cli.py pass.
No changes to test_executor.py or test_agamemnon_client.py.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Signed-off-by: mvillmow <4211002+mvillmow@users.noreply.github.com>
GHSA-4xgf-cpjx-pc3j)

Signed-off-by: Micah Villmow <4211002+mvillmow@users.noreply.github.com>
@mvillmow mvillmow merged commit 06cbe0a into main Jun 29, 2026
15 checks passed
@mvillmow mvillmow deleted the 149-auto-impl branch June 29, 2026 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[MINOR] §5: Test fixtures use hardcoded YAML strings rather than parameterized factories

1 participant