slimtest 0.2.0__tar.gz → 0.3.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {slimtest-0.2.0 → slimtest-0.3.1}/.github/workflows/ci.yml +43 -0
- slimtest-0.3.1/.release-please-manifest.json +3 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/CHANGELOG.md +14 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/PKG-INFO +3 -1
- {slimtest-0.2.0 → slimtest-0.3.1}/README.md +2 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/pyproject.toml +1 -1
- {slimtest-0.2.0 → slimtest-0.3.1}/src/slimtest/cli.py +45 -5
- {slimtest-0.2.0 → slimtest-0.3.1}/src/slimtest/dbt_runner.py +53 -4
- {slimtest-0.2.0 → slimtest-0.3.1}/src/slimtest/runner.py +23 -6
- {slimtest-0.2.0 → slimtest-0.3.1}/tests/test_cli.py +87 -3
- {slimtest-0.2.0 → slimtest-0.3.1}/tests/test_dbt_runner.py +43 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/tests/test_runner.py +36 -2
- {slimtest-0.2.0 → slimtest-0.3.1}/uv.lock +1 -1
- slimtest-0.2.0/.release-please-manifest.json +0 -3
- {slimtest-0.2.0 → slimtest-0.3.1}/.github/CODEOWNERS +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/.github/workflows/pr-title.yml +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/.github/workflows/release-testpypi.yml +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/.github/workflows/release.yml +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/.gitignore +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/AGENTS.md +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/LICENSE +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/examples/sample_dbt_project/.gitignore +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/examples/sample_dbt_project/README.md +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/examples/sample_dbt_project/dbt_project.yml +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/examples/sample_dbt_project/macros/sample_execution_context.sql +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/examples/sample_dbt_project/models/marts/order_statuses.sql +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/examples/sample_dbt_project/models/marts/order_statuses.yml +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/examples/sample_dbt_project/profiles.yml +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/examples/sample_dbt_project/seeds/customers.csv +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/examples/sample_dbt_project/seeds/order_events.csv +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/examples/sample_dbt_project/seeds/orders.csv +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/examples/sample_dbt_project/seeds/products.csv +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/examples/sample_dbt_project/tests/slimtest_factories/customers.yml +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/examples/sample_dbt_project/tests/slimtest_factories/order_events.yml +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/examples/sample_dbt_project/tests/slimtest_factories/orders.yml +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/examples/sample_dbt_project/tests/slimtest_factories/products.yml +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/release-please-config.json +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/src/slimtest/__init__.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/src/slimtest/compile.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/src/slimtest/config.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/src/slimtest/dbt_project.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/src/slimtest/deep_merge.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/src/slimtest/expand.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/src/slimtest/factory.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/src/slimtest/manifest.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/src/slimtest/model_parser.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/src/slimtest/parametrize.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/src/slimtest/result_parser.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/src/slimtest/scenario.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/src/slimtest/schema.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/src/slimtest/selector.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/tests/__init__.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/tests/conftest.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/tests/test_compile.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/tests/test_config.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/tests/test_dbt_project.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/tests/test_deep_merge.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/tests/test_expand.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/tests/test_factory.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/tests/test_manifest.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/tests/test_model_parser.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/tests/test_parametrize.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/tests/test_result_parser.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/tests/test_scenario.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/tests/test_schema.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.1}/tests/test_selector.py +0 -0
|
@@ -43,3 +43,46 @@ jobs:
|
|
|
43
43
|
|
|
44
44
|
- name: Test (pytest)
|
|
45
45
|
run: uv run --python ${{ matrix.python-version }} pytest -q
|
|
46
|
+
|
|
47
|
+
example-e2e:
|
|
48
|
+
name: example / dbt-duckdb
|
|
49
|
+
runs-on: ubuntu-latest
|
|
50
|
+
timeout-minutes: 10
|
|
51
|
+
steps:
|
|
52
|
+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
|
53
|
+
|
|
54
|
+
- name: Install uv
|
|
55
|
+
uses: astral-sh/setup-uv@caf0cab7a618c569241d31dcd442f54681755d39 # v3.2.4
|
|
56
|
+
with:
|
|
57
|
+
enable-cache: true
|
|
58
|
+
|
|
59
|
+
- name: Set up Python 3.11
|
|
60
|
+
run: uv python install 3.11
|
|
61
|
+
|
|
62
|
+
- name: Sync dependencies
|
|
63
|
+
run: uv sync --python 3.11
|
|
64
|
+
|
|
65
|
+
- name: Prepare sample dbt project
|
|
66
|
+
working-directory: examples/sample_dbt_project
|
|
67
|
+
run: |
|
|
68
|
+
uv run --project ../.. --with dbt-duckdb \
|
|
69
|
+
dbt seed \
|
|
70
|
+
--profiles-dir . \
|
|
71
|
+
--profile slimtest_sample \
|
|
72
|
+
--target dev
|
|
73
|
+
|
|
74
|
+
uv run --project ../.. --with dbt-duckdb \
|
|
75
|
+
dbt run \
|
|
76
|
+
--profiles-dir . \
|
|
77
|
+
--profile slimtest_sample \
|
|
78
|
+
--target dev
|
|
79
|
+
|
|
80
|
+
- name: Run slimtest example
|
|
81
|
+
working-directory: examples/sample_dbt_project
|
|
82
|
+
run: |
|
|
83
|
+
uv run --project ../.. --with dbt-duckdb \
|
|
84
|
+
slimtest unittest \
|
|
85
|
+
--project-dir . \
|
|
86
|
+
--profiles-dir . \
|
|
87
|
+
--profile slimtest_sample \
|
|
88
|
+
--target dev
|
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
4
4
|
|
|
5
|
+
## [0.3.1](https://github.com/Hisaaki-Kato/slimtest/compare/v0.3.0...v0.3.1) (2026-08-06)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* surface dbt errors when unittest produces no results ([#14](https://github.com/Hisaaki-Kato/slimtest/issues/14)) ([31ad3be](https://github.com/Hisaaki-Kato/slimtest/commit/31ad3bed9a4c414dacb66fff930348cb5b8174cb))
|
|
11
|
+
|
|
12
|
+
## [0.3.0](https://github.com/Hisaaki-Kato/slimtest/compare/v0.2.0...v0.3.0) (2026-08-05)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* support dbt profile and target options ([#11](https://github.com/Hisaaki-Kato/slimtest/issues/11)) ([db0b542](https://github.com/Hisaaki-Kato/slimtest/commit/db0b5423735d3682a9907108f0e7e1dbf2e132d0))
|
|
18
|
+
|
|
5
19
|
## [0.2.0](https://github.com/Hisaaki-Kato/slimtest/compare/v0.1.1...v0.2.0) (2026-07-31)
|
|
6
20
|
|
|
7
21
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: slimtest
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.1
|
|
4
4
|
Summary: Factory + trait DSL on top of dbt unit tests.
|
|
5
5
|
Project-URL: Homepage, https://github.com/Hisaaki-Kato/slimtest
|
|
6
6
|
Project-URL: Repository, https://github.com/Hisaaki-Kato/slimtest
|
|
@@ -388,6 +388,8 @@ slimtest compile [--project-dir DIR] [--select SEL]
|
|
|
388
388
|
Does NOT invoke dbt. Useful for debugging the expansion.
|
|
389
389
|
|
|
390
390
|
slimtest unittest [--project-dir DIR] [--select SEL]
|
|
391
|
+
[--target TARGET] [--profile PROFILE]
|
|
392
|
+
[--profiles-dir DIR]
|
|
391
393
|
1. dbt parse (refresh target/manifest.json)
|
|
392
394
|
2. slimtest compile
|
|
393
395
|
3. dbt test --select <generated test names>
|
|
@@ -357,6 +357,8 @@ slimtest compile [--project-dir DIR] [--select SEL]
|
|
|
357
357
|
Does NOT invoke dbt. Useful for debugging the expansion.
|
|
358
358
|
|
|
359
359
|
slimtest unittest [--project-dir DIR] [--select SEL]
|
|
360
|
+
[--target TARGET] [--profile PROFILE]
|
|
361
|
+
[--profiles-dir DIR]
|
|
360
362
|
1. dbt parse (refresh target/manifest.json)
|
|
361
363
|
2. slimtest compile
|
|
362
364
|
3. dbt test --select <generated test names>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""slimtest CLI entry point.
|
|
2
2
|
|
|
3
|
-
`compile`
|
|
4
|
-
|
|
3
|
+
`compile` expands slimtest definitions and `unittest` runs the generated
|
|
4
|
+
tests through dbt.
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
7
|
from __future__ import annotations
|
|
@@ -46,6 +46,30 @@ SelectOption = Annotated[
|
|
|
46
46
|
),
|
|
47
47
|
]
|
|
48
48
|
|
|
49
|
+
TargetOption = Annotated[
|
|
50
|
+
str | None,
|
|
51
|
+
typer.Option(
|
|
52
|
+
"--target",
|
|
53
|
+
help="dbt target to use from the selected profile.",
|
|
54
|
+
),
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
ProfileOption = Annotated[
|
|
58
|
+
str | None,
|
|
59
|
+
typer.Option(
|
|
60
|
+
"--profile",
|
|
61
|
+
help="dbt profile name to use.",
|
|
62
|
+
),
|
|
63
|
+
]
|
|
64
|
+
|
|
65
|
+
ProfilesDirOption = Annotated[
|
|
66
|
+
Path | None,
|
|
67
|
+
typer.Option(
|
|
68
|
+
"--profiles-dir",
|
|
69
|
+
help="Directory containing dbt's profiles.yml.",
|
|
70
|
+
),
|
|
71
|
+
]
|
|
72
|
+
|
|
49
73
|
VerboseOption = Annotated[
|
|
50
74
|
bool,
|
|
51
75
|
typer.Option(
|
|
@@ -104,11 +128,20 @@ def compile( # noqa: A001 -- shadowing builtin is fine for a CLI verb
|
|
|
104
128
|
def unittest(
|
|
105
129
|
project_dir: ProjectDirOption = Path("."),
|
|
106
130
|
select: SelectOption = None,
|
|
131
|
+
target: TargetOption = None,
|
|
132
|
+
profile: ProfileOption = None,
|
|
133
|
+
profiles_dir: ProfilesDirOption = None,
|
|
107
134
|
verbose: VerboseOption = False,
|
|
108
135
|
) -> None:
|
|
109
136
|
"""Compile + run the resulting unit tests via `dbt test`."""
|
|
110
137
|
try:
|
|
111
|
-
result = unittest_project(
|
|
138
|
+
result = unittest_project(
|
|
139
|
+
project_dir,
|
|
140
|
+
select=select,
|
|
141
|
+
target=target,
|
|
142
|
+
profile=profile,
|
|
143
|
+
profiles_dir=profiles_dir,
|
|
144
|
+
)
|
|
112
145
|
except SlimTestError as exc:
|
|
113
146
|
typer.echo(f"[slimtest] error: {exc}", err=True)
|
|
114
147
|
raise typer.Exit(code=1) from exc
|
|
@@ -156,8 +189,15 @@ def _print_unittest_result(result: UnittestResult, *, verbose: bool = False) ->
|
|
|
156
189
|
_print_failure(entry)
|
|
157
190
|
|
|
158
191
|
if result.summary.total == 0 and not result.test_result.ok:
|
|
159
|
-
|
|
160
|
-
|
|
192
|
+
typer.echo(
|
|
193
|
+
"[slimtest] error: `dbt test` exited "
|
|
194
|
+
f"{result.test_result.exit_code} without producing test results.",
|
|
195
|
+
err=True,
|
|
196
|
+
)
|
|
197
|
+
# dbt writes most logs to stdout, but adapters may use stderr.
|
|
198
|
+
for output in (result.test_result.stdout, result.test_result.stderr):
|
|
199
|
+
if output.strip():
|
|
200
|
+
typer.echo(output.rstrip(), err=True)
|
|
161
201
|
|
|
162
202
|
|
|
163
203
|
def _print_failure(entry: EnrichedOutcome) -> None:
|
|
@@ -95,12 +95,52 @@ def run_dbt(
|
|
|
95
95
|
)
|
|
96
96
|
|
|
97
97
|
|
|
98
|
-
def
|
|
98
|
+
def _profile_args(
|
|
99
|
+
*,
|
|
100
|
+
target: str | None,
|
|
101
|
+
profile: str | None,
|
|
102
|
+
profiles_dir: Path | None,
|
|
103
|
+
) -> list[str]:
|
|
104
|
+
"""Build dbt CLI arguments that select a profile and target."""
|
|
105
|
+
args: list[str] = []
|
|
106
|
+
if target is not None:
|
|
107
|
+
args.extend(("--target", target))
|
|
108
|
+
if profile is not None:
|
|
109
|
+
args.extend(("--profile", profile))
|
|
110
|
+
if profiles_dir is not None:
|
|
111
|
+
args.extend(("--profiles-dir", str(profiles_dir)))
|
|
112
|
+
return args
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def dbt_parse(
|
|
116
|
+
project_root: Path,
|
|
117
|
+
*,
|
|
118
|
+
target: str | None = None,
|
|
119
|
+
profile: str | None = None,
|
|
120
|
+
profiles_dir: Path | None = None,
|
|
121
|
+
) -> DbtResult:
|
|
99
122
|
"""Run `dbt parse` to rebuild `target/manifest.json`."""
|
|
100
|
-
return run_dbt(
|
|
123
|
+
return run_dbt(
|
|
124
|
+
[
|
|
125
|
+
"parse",
|
|
126
|
+
*_profile_args(
|
|
127
|
+
target=target,
|
|
128
|
+
profile=profile,
|
|
129
|
+
profiles_dir=profiles_dir,
|
|
130
|
+
),
|
|
131
|
+
],
|
|
132
|
+
project_root,
|
|
133
|
+
)
|
|
101
134
|
|
|
102
135
|
|
|
103
|
-
def dbt_test(
|
|
136
|
+
def dbt_test(
|
|
137
|
+
project_root: Path,
|
|
138
|
+
test_names: list[str],
|
|
139
|
+
*,
|
|
140
|
+
target: str | None = None,
|
|
141
|
+
profile: str | None = None,
|
|
142
|
+
profiles_dir: Path | None = None,
|
|
143
|
+
) -> DbtResult:
|
|
104
144
|
"""Run `dbt test --select <names>`.
|
|
105
145
|
|
|
106
146
|
An empty `test_names` list returns a synthetic success so callers
|
|
@@ -109,7 +149,16 @@ def dbt_test(project_root: Path, test_names: list[str]) -> DbtResult:
|
|
|
109
149
|
if not test_names:
|
|
110
150
|
return DbtResult(exit_code=0, stdout="", stderr="")
|
|
111
151
|
return run_dbt(
|
|
112
|
-
[
|
|
152
|
+
[
|
|
153
|
+
"test",
|
|
154
|
+
"--select",
|
|
155
|
+
" ".join(test_names),
|
|
156
|
+
*_profile_args(
|
|
157
|
+
target=target,
|
|
158
|
+
profile=profile,
|
|
159
|
+
profiles_dir=profiles_dir,
|
|
160
|
+
),
|
|
161
|
+
],
|
|
113
162
|
project_root,
|
|
114
163
|
)
|
|
115
164
|
|
|
@@ -53,20 +53,37 @@ class UnittestResult:
|
|
|
53
53
|
|
|
54
54
|
|
|
55
55
|
def unittest_project(
|
|
56
|
-
project_root: Path,
|
|
56
|
+
project_root: Path,
|
|
57
|
+
*,
|
|
58
|
+
select: str | None = None,
|
|
59
|
+
target: str | None = None,
|
|
60
|
+
profile: str | None = None,
|
|
61
|
+
profiles_dir: Path | None = None,
|
|
57
62
|
) -> UnittestResult:
|
|
58
63
|
"""End-to-end `slimtest unittest` orchestration.
|
|
59
64
|
|
|
60
|
-
`dbt parse` is best-effort: a non-zero exit is reported on the
|
|
61
|
-
|
|
62
|
-
`
|
|
65
|
+
`dbt parse` is best-effort: a non-zero exit is reported on the result but
|
|
66
|
+
does not abort the run. `select` is forwarded to `compile_project` (see
|
|
67
|
+
`selector.py`). Profile and target options are forwarded consistently to
|
|
68
|
+
both dbt invocations.
|
|
63
69
|
"""
|
|
64
70
|
project_root = project_root.resolve()
|
|
65
71
|
|
|
66
|
-
parse_result = dbt_parse(
|
|
72
|
+
parse_result = dbt_parse(
|
|
73
|
+
project_root,
|
|
74
|
+
target=target,
|
|
75
|
+
profile=profile,
|
|
76
|
+
profiles_dir=profiles_dir,
|
|
77
|
+
)
|
|
67
78
|
manifest = _try_manifest(project_root)
|
|
68
79
|
compile_result = compile_project(project_root, manifest=manifest, select=select)
|
|
69
|
-
test_result = dbt_test(
|
|
80
|
+
test_result = dbt_test(
|
|
81
|
+
project_root,
|
|
82
|
+
compile_result.test_names,
|
|
83
|
+
target=target,
|
|
84
|
+
profile=profile,
|
|
85
|
+
profiles_dir=profiles_dir,
|
|
86
|
+
)
|
|
70
87
|
|
|
71
88
|
outcomes = _enrich_outcomes(project_root, compile_result)
|
|
72
89
|
summary = summarize([e.outcome for e in outcomes])
|
|
@@ -5,6 +5,7 @@ from __future__ import annotations
|
|
|
5
5
|
import re
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
|
|
8
|
+
import pytest
|
|
8
9
|
from typer.testing import CliRunner
|
|
9
10
|
|
|
10
11
|
from slimtest import __version__
|
|
@@ -119,7 +120,11 @@ class TestUnittestCommand:
|
|
|
119
120
|
def test_unittest_help(self):
|
|
120
121
|
result = _run("unittest", "--help")
|
|
121
122
|
assert result.exit_code == 0
|
|
122
|
-
|
|
123
|
+
output = _plain(result.output)
|
|
124
|
+
assert "--project-dir" in output
|
|
125
|
+
assert "--target" in output
|
|
126
|
+
assert "--profile" in output
|
|
127
|
+
assert "--profiles-dir" in output
|
|
123
128
|
|
|
124
129
|
def test_unittest_reports_summary_and_exits_zero_on_success(
|
|
125
130
|
self, monkeypatch, tmp_path: Path
|
|
@@ -161,10 +166,35 @@ class TestUnittestCommand:
|
|
|
161
166
|
],
|
|
162
167
|
summary=TestSummary(total=1, passed=1, failed=0, errored=0, skipped=0),
|
|
163
168
|
)
|
|
164
|
-
|
|
165
|
-
|
|
169
|
+
captured = {}
|
|
170
|
+
|
|
171
|
+
def fake_unittest_project(root, **kwargs):
|
|
172
|
+
captured["root"] = root
|
|
173
|
+
captured.update(kwargs)
|
|
174
|
+
return fake
|
|
175
|
+
|
|
176
|
+
monkeypatch.setattr("slimtest.cli.unittest_project", fake_unittest_project)
|
|
177
|
+
profiles_dir = tmp_path / "dbt-profiles"
|
|
178
|
+
result = _run(
|
|
179
|
+
"unittest",
|
|
180
|
+
"--project-dir",
|
|
181
|
+
str(tmp_path),
|
|
182
|
+
"--target",
|
|
183
|
+
"ci",
|
|
184
|
+
"--profile",
|
|
185
|
+
"analytics",
|
|
186
|
+
"--profiles-dir",
|
|
187
|
+
str(profiles_dir),
|
|
188
|
+
)
|
|
166
189
|
assert result.exit_code == 0
|
|
167
190
|
assert "1/1 passed" in _plain(result.output)
|
|
191
|
+
assert captured == {
|
|
192
|
+
"root": tmp_path,
|
|
193
|
+
"select": None,
|
|
194
|
+
"target": "ci",
|
|
195
|
+
"profile": "analytics",
|
|
196
|
+
"profiles_dir": profiles_dir,
|
|
197
|
+
}
|
|
168
198
|
|
|
169
199
|
def test_unittest_exits_one_when_a_test_fails(self, monkeypatch, tmp_path: Path):
|
|
170
200
|
from slimtest.compile import CompileResult
|
|
@@ -210,3 +240,57 @@ class TestUnittestCommand:
|
|
|
210
240
|
# Failure is rendered with source location.
|
|
211
241
|
assert "FAIL: t" in _plain(result.output)
|
|
212
242
|
assert "models/m.yml:42" in _plain(result.output)
|
|
243
|
+
|
|
244
|
+
@pytest.mark.parametrize(
|
|
245
|
+
("stdout", "stderr", "diagnostics"),
|
|
246
|
+
[
|
|
247
|
+
("stdout diagnostic", "", ["stdout diagnostic"]),
|
|
248
|
+
("", "stderr diagnostic", ["stderr diagnostic"]),
|
|
249
|
+
(
|
|
250
|
+
"stdout diagnostic",
|
|
251
|
+
"stderr diagnostic",
|
|
252
|
+
["stdout diagnostic", "stderr diagnostic"],
|
|
253
|
+
),
|
|
254
|
+
],
|
|
255
|
+
)
|
|
256
|
+
def test_unittest_surfaces_dbt_output_when_no_results_are_produced(
|
|
257
|
+
self,
|
|
258
|
+
monkeypatch,
|
|
259
|
+
tmp_path: Path,
|
|
260
|
+
stdout: str,
|
|
261
|
+
stderr: str,
|
|
262
|
+
diagnostics: list[str],
|
|
263
|
+
):
|
|
264
|
+
from slimtest.compile import CompileResult
|
|
265
|
+
from slimtest.dbt_runner import DbtResult
|
|
266
|
+
from slimtest.result_parser import TestSummary
|
|
267
|
+
from slimtest.runner import UnittestResult
|
|
268
|
+
from slimtest.schema import SlimTestConfig
|
|
269
|
+
|
|
270
|
+
compile_result = CompileResult(
|
|
271
|
+
project_root=tmp_path,
|
|
272
|
+
config=SlimTestConfig(),
|
|
273
|
+
output_dir=tmp_path / "target/slimtest",
|
|
274
|
+
generated_files=[],
|
|
275
|
+
source_map_path=tmp_path / "target/slimtest/source_map.json",
|
|
276
|
+
source_map={},
|
|
277
|
+
test_names=["slimtest__m__t"],
|
|
278
|
+
warnings=[],
|
|
279
|
+
notices=[],
|
|
280
|
+
)
|
|
281
|
+
fake = UnittestResult(
|
|
282
|
+
compile=compile_result,
|
|
283
|
+
parse_result=DbtResult(0, "", ""),
|
|
284
|
+
test_result=DbtResult(2, stdout, stderr),
|
|
285
|
+
outcomes=[],
|
|
286
|
+
summary=TestSummary(total=0, passed=0, failed=0, errored=0, skipped=0),
|
|
287
|
+
)
|
|
288
|
+
monkeypatch.setattr("slimtest.cli.unittest_project", lambda _root, **_kw: fake)
|
|
289
|
+
|
|
290
|
+
result = _run("unittest", "--project-dir", str(tmp_path))
|
|
291
|
+
|
|
292
|
+
output = _plain(result.output)
|
|
293
|
+
assert result.exit_code == 1
|
|
294
|
+
assert "`dbt test` exited 2 without producing test results" in output
|
|
295
|
+
for diagnostic in diagnostics:
|
|
296
|
+
assert diagnostic in output
|
|
@@ -137,6 +137,26 @@ class TestDbtParse:
|
|
|
137
137
|
dbt_parse(tmp_path)
|
|
138
138
|
assert recorder.calls[0]["args"] == ["dbt", "parse"]
|
|
139
139
|
|
|
140
|
+
def test_passes_profile_and_target_options(self, monkeypatch, tmp_path):
|
|
141
|
+
recorder = _RecordingRun()
|
|
142
|
+
monkeypatch.setattr("slimtest.dbt_runner.subprocess.run", recorder)
|
|
143
|
+
dbt_parse(
|
|
144
|
+
tmp_path,
|
|
145
|
+
target="ci",
|
|
146
|
+
profile="analytics",
|
|
147
|
+
profiles_dir=tmp_path / "dbt-profiles",
|
|
148
|
+
)
|
|
149
|
+
assert recorder.calls[0]["args"] == [
|
|
150
|
+
"dbt",
|
|
151
|
+
"parse",
|
|
152
|
+
"--target",
|
|
153
|
+
"ci",
|
|
154
|
+
"--profile",
|
|
155
|
+
"analytics",
|
|
156
|
+
"--profiles-dir",
|
|
157
|
+
str(tmp_path / "dbt-profiles"),
|
|
158
|
+
]
|
|
159
|
+
|
|
140
160
|
|
|
141
161
|
@pytest.mark.usefixtures("_have_dbt")
|
|
142
162
|
class TestDbtTest:
|
|
@@ -147,6 +167,29 @@ class TestDbtTest:
|
|
|
147
167
|
# Names are joined into one --select token, space separated.
|
|
148
168
|
assert recorder.calls[0]["args"] == ["dbt", "test", "--select", "a b"]
|
|
149
169
|
|
|
170
|
+
def test_passes_profile_and_target_options(self, monkeypatch, tmp_path):
|
|
171
|
+
recorder = _RecordingRun()
|
|
172
|
+
monkeypatch.setattr("slimtest.dbt_runner.subprocess.run", recorder)
|
|
173
|
+
dbt_test(
|
|
174
|
+
tmp_path,
|
|
175
|
+
["a"],
|
|
176
|
+
target="ci",
|
|
177
|
+
profile="analytics",
|
|
178
|
+
profiles_dir=tmp_path / "dbt-profiles",
|
|
179
|
+
)
|
|
180
|
+
assert recorder.calls[0]["args"] == [
|
|
181
|
+
"dbt",
|
|
182
|
+
"test",
|
|
183
|
+
"--select",
|
|
184
|
+
"a",
|
|
185
|
+
"--target",
|
|
186
|
+
"ci",
|
|
187
|
+
"--profile",
|
|
188
|
+
"analytics",
|
|
189
|
+
"--profiles-dir",
|
|
190
|
+
str(tmp_path / "dbt-profiles"),
|
|
191
|
+
]
|
|
192
|
+
|
|
150
193
|
def test_empty_test_list_short_circuits(self, monkeypatch, tmp_path):
|
|
151
194
|
recorder = _RecordingRun()
|
|
152
195
|
monkeypatch.setattr("slimtest.dbt_runner.subprocess.run", recorder)
|
|
@@ -10,6 +10,7 @@ from __future__ import annotations
|
|
|
10
10
|
import json
|
|
11
11
|
import textwrap
|
|
12
12
|
from pathlib import Path
|
|
13
|
+
from typing import Any
|
|
13
14
|
|
|
14
15
|
from slimtest.dbt_runner import DbtResult
|
|
15
16
|
from slimtest.runner import unittest_project
|
|
@@ -58,14 +59,47 @@ _DBT_OK = DbtResult(0, "", "")
|
|
|
58
59
|
def _fake_dbt(monkeypatch, *, parse=None, test=None):
|
|
59
60
|
parse = parse if parse is not None else _DBT_OK
|
|
60
61
|
test = test if test is not None else _DBT_OK
|
|
61
|
-
monkeypatch.setattr("slimtest.runner.dbt_parse", lambda _root: parse)
|
|
62
|
-
monkeypatch.setattr(
|
|
62
|
+
monkeypatch.setattr("slimtest.runner.dbt_parse", lambda _root, **_kwargs: parse)
|
|
63
|
+
monkeypatch.setattr(
|
|
64
|
+
"slimtest.runner.dbt_test", lambda _root, _names, **_kwargs: test
|
|
65
|
+
)
|
|
63
66
|
|
|
64
67
|
|
|
65
68
|
# -- happy path -----------------------------------------------------
|
|
66
69
|
|
|
67
70
|
|
|
68
71
|
class TestUnittestProject:
|
|
72
|
+
def test_forwards_profile_and_target_options(self, monkeypatch, tmp_path):
|
|
73
|
+
_make_minimal_project(tmp_path, with_test=False)
|
|
74
|
+
calls: list[tuple[Any, ...]] = []
|
|
75
|
+
|
|
76
|
+
def fake_parse(root, **kwargs):
|
|
77
|
+
calls.append(("parse", root, kwargs))
|
|
78
|
+
return _DBT_OK
|
|
79
|
+
|
|
80
|
+
def fake_test(root, names, **kwargs):
|
|
81
|
+
calls.append(("test", root, names, kwargs))
|
|
82
|
+
return _DBT_OK
|
|
83
|
+
|
|
84
|
+
monkeypatch.setattr("slimtest.runner.dbt_parse", fake_parse)
|
|
85
|
+
monkeypatch.setattr("slimtest.runner.dbt_test", fake_test)
|
|
86
|
+
profiles_dir = tmp_path / "dbt-profiles"
|
|
87
|
+
|
|
88
|
+
unittest_project(
|
|
89
|
+
tmp_path,
|
|
90
|
+
target="ci",
|
|
91
|
+
profile="analytics",
|
|
92
|
+
profiles_dir=profiles_dir,
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
expected = {
|
|
96
|
+
"target": "ci",
|
|
97
|
+
"profile": "analytics",
|
|
98
|
+
"profiles_dir": profiles_dir,
|
|
99
|
+
}
|
|
100
|
+
assert calls[0] == ("parse", tmp_path.resolve(), expected)
|
|
101
|
+
assert calls[1] == ("test", tmp_path.resolve(), [], expected)
|
|
102
|
+
|
|
69
103
|
def test_zero_tests_returns_ok(self, monkeypatch, tmp_path):
|
|
70
104
|
_make_minimal_project(tmp_path, with_test=False)
|
|
71
105
|
_fake_dbt(monkeypatch)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{slimtest-0.2.0 → slimtest-0.3.1}/examples/sample_dbt_project/macros/sample_execution_context.sql
RENAMED
|
File without changes
|
{slimtest-0.2.0 → slimtest-0.3.1}/examples/sample_dbt_project/models/marts/order_statuses.sql
RENAMED
|
File without changes
|
{slimtest-0.2.0 → slimtest-0.3.1}/examples/sample_dbt_project/models/marts/order_statuses.yml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{slimtest-0.2.0 → slimtest-0.3.1}/examples/sample_dbt_project/tests/slimtest_factories/customers.yml
RENAMED
|
File without changes
|
|
File without changes
|
{slimtest-0.2.0 → slimtest-0.3.1}/examples/sample_dbt_project/tests/slimtest_factories/orders.yml
RENAMED
|
File without changes
|
{slimtest-0.2.0 → slimtest-0.3.1}/examples/sample_dbt_project/tests/slimtest_factories/products.yml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|