Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 8 additions & 28 deletions tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,45 +76,25 @@ def make_config(
Returns a ``ToolkitConfig`` with real Pydantic models — no dict mocks.
All attribute access (``cfg.clean.sql``, ``cfg.mart.tables``) works.
"""
from toolkit.core.config_models import (
ToolkitConfigModel,
DatasetBlock,
RawConfig,
CleanConfig,
MartConfig,
)
from toolkit.core.config import PipelineConfig, RawConfig, CleanConfig, MartConfig

_root = root or Path("/tmp/toolkit-test-root")
_base = base_dir or _root
_years = years or [2024]

model = ToolkitConfigModel(
return PipelineConfig(
base_dir=_base,
root=_root,
root_source="test",
dataset=DatasetBlock(name=dataset, years=_years, source_id=source_id),
raw=RawConfig.model_validate(raw or {}),
clean=CleanConfig.model_validate(clean or {}),
mart=MartConfig.model_validate(mart or {}),
dataset=dataset,
source_id=source_id,
years=_years,
raw=RawConfig.from_dict(raw or {}),
clean=CleanConfig.from_dict(clean or {}),
mart=MartConfig.from_dict(mart or {}),
support=support or [],
)

from toolkit.core.config import ToolkitConfig

return ToolkitConfig(
base_dir=model.base_dir,
schema_version=model.schema_version,
root=model.root,
root_source=model.root_source,
dataset=model.dataset.name,
source_id=model.dataset.source_id,
years=list(model.dataset.years),
time_coverage=model.dataset.time_coverage,
tags=list(model.dataset.tags or []),
category=model.dataset.category,
_model=model,
)


def make_standard_sql(base_dir: Path, /) -> dict[str, Path]:
"""Create standard ``sql/clean.sql`` and ``sql/mart/mart_example.sql``.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_clean_csv_columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ def test_run_clean_align_by_header_integration(tmp_path: Path):
@pytest.mark.policy
def test_run_clean_align_by_header_requires_normalize_config():
"""CleanReadConfig con align_by_header=true senza normalize_rows_to_columns alza ValueError."""
from toolkit.core.config_models.clean import CleanReadConfig
from toolkit.core.config import CleanReadConfig

with pytest.raises(
ValueError, match="align_by_header=true requires normalize_rows_to_columns=true"
Expand Down
Loading
Loading