orchestrata_tools.test_generator.testgen.config

Reference › orchestrata_tools › test_generator › testgen › config

This module holds the project-specific configuration for test generation. ProjectConfig is a dataclass with these settings: a package prefix for imports, whether to include branch-condition tests (on by default), whether to emit entry-point stubs (off by default), an allowed-standard-library import set, custom sentinel recipes for project types, a hook for the generated test file, and a file name pattern (test_{mod_name}.py by default). get_config returns a predefined configuration by name, or a default one. A mock-test switch was deliberately removed rather than defaulted off, because the project rule is that tests do not mock. generator, branch, structural and types take it as an argument. It was restored in August 2026 from a deleted earlier generator tree.

At a glance

Source src/orchestrata_tools/test_generator/testgen/config.py
Lines of code 77
Classes 1
Functions 1
Imports (internal) none
Imported by orchestrata_tools.test_generator.testgen, orchestrata_tools.test_generator.testgen.branch, orchestrata_tools.test_generator.testgen.generator, orchestrata_tools.test_generator.testgen.structural, orchestrata_tools.test_generator.testgen.types, orchestrata_tools.test_generator.testgen.writer
Tests that import it tests/scripts/test_ast_branches.py, tests/test_orchestrata_tools_testgen_config_coverage.py, tests/test_orchestrata_tools_testgen_generator_coverage.py, tests/test_orchestrata_tools_testgen_structural_coverage.py, tests/test_orchestrata_tools_testgen_types_coverage.py, tests/test_orchestrata_tools_testgen_units.py

Class diagram

Class diagram orchestrata_tools.test_generator.testgen.config

Dependency diagram

Dependency diagram orchestrata_tools.test_generator.testgen.config

API

Classes

ProjectConfig (dataclass)

Decorators: dataclass · Line 23

Configuration that controls how tests are generated for a project.

Attribute Type Default
package_prefix str ''
enable_branch_tests bool True
enable_entry_point_stubs bool False
allowed_stdlib_imports set[str] field(default_factory=lambda: {'datetime', 'uuid', 'pathlib…
custom_sentinels dict[str, tuple[str, list[str]]] field(default_factory=dict)
testfile_hook Any | None None
test_file_pattern str 'test_{mod_name}.py'

Functions

Function Signature Summary
get_config get_config(name: str | None = None) -> ProjectConfig Return a pre-defined config by name, or a default config.

Source

Permalink: https://gitlab.com/MSamy/orchestrata-ultimate-architecture/-/blob/a4cbc2bdf/src/orchestrata_tools/test_generator/testgen/config.py

"""config.py — Project-specific configuration for test generation.

Add a new config by creating a dict and passing it to generate_tests()
via the project_config parameter.

Restored 2026-08-19 from ``scripts/ast_serializer/testgen`` (deleted
2026-07-09, commit 6a186c9d) and re-pointed at the current AST layer
(``orchestrata_ast`` + ``scripts/serialize_codebase_ast.py``) — see
``orchestrata_tools.test_generator.testgen.adapter`` for the bridge.
``enable_mock_tests`` was dropped outright rather than defaulted off: this
project's hard rule is "no mocking, ever" (the only sanctioned test double
is the LLM boundary), so a toggle that could ever emit ``unittest.mock``
code has no legitimate "on" state to keep around.
"""

from __future__ import annotations

from dataclasses import dataclass, field
from typing import Any


@dataclass
class ProjectConfig:
    """Configuration that controls how tests are generated for a project."""

    # Package prefix for imports (e.g. "orchestrata_ultimate")
    package_prefix: str = ""

    # Whether to include branch-condition tests
    enable_branch_tests: bool = True

    # Whether to include ranked-entry-point TODO stub tests (Layer 1).
    # Off by default: these are placeholder-only ("pass  # TODO: fill in"),
    # low value next to real branch tests. Named for what it now does —
    # was "enable_mock_tests" before the mocked-dependency variant was
    # dropped outright (this project's hard rule: no mocking, ever).
    enable_entry_point_stubs: bool = False

    # Modules that are allowed to be imported in generated tests
    allowed_stdlib_imports: set[str] = field(
        default_factory=lambda: {
            "datetime",
            "uuid",
            "pathlib",
            "collections",
            "typing",
            "enum",
            "dataclasses",
            "json",
            "re",
            "os",
            "sys",
        }
    )

    # Custom sentinel overrides for project-specific types
    custom_sentinels: dict[str, tuple[str, list[str]]] = field(default_factory=dict)

    # Hook: called after a TestFile is created, allows custom modifications
    testfile_hook: Any | None = None

    # Pattern for test file names
    test_file_pattern: str = "test_{mod_name}.py"


# Pre-defined configs for known projects
ORCHESTRATA_ULTIMATE = ProjectConfig(
    package_prefix="orchestrata_ultimate",
    enable_branch_tests=True,
)


def get_config(name: str | None = None) -> ProjectConfig:
    """Return a pre-defined config by name, or a default config."""
    if name == "orchestrata_ultimate":
        return ORCHESTRATA_ULTIMATE
    return ProjectConfig()