slimtest 0.2.0__tar.gz → 0.3.0__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.0}/.github/workflows/ci.yml +43 -0
- slimtest-0.3.0/.release-please-manifest.json +3 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/CHANGELOG.md +7 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/PKG-INFO +3 -1
- {slimtest-0.2.0 → slimtest-0.3.0}/README.md +2 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/pyproject.toml +1 -1
- {slimtest-0.2.0 → slimtest-0.3.0}/src/slimtest/cli.py +36 -3
- {slimtest-0.2.0 → slimtest-0.3.0}/src/slimtest/dbt_runner.py +53 -4
- {slimtest-0.2.0 → slimtest-0.3.0}/src/slimtest/runner.py +23 -6
- {slimtest-0.2.0 → slimtest-0.3.0}/tests/test_cli.py +32 -3
- {slimtest-0.2.0 → slimtest-0.3.0}/tests/test_dbt_runner.py +43 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/tests/test_runner.py +36 -2
- {slimtest-0.2.0 → slimtest-0.3.0}/uv.lock +1 -1
- slimtest-0.2.0/.release-please-manifest.json +0 -3
- {slimtest-0.2.0 → slimtest-0.3.0}/.github/CODEOWNERS +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/.github/workflows/pr-title.yml +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/.github/workflows/release-testpypi.yml +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/.github/workflows/release.yml +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/.gitignore +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/AGENTS.md +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/LICENSE +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/examples/sample_dbt_project/.gitignore +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/examples/sample_dbt_project/README.md +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/examples/sample_dbt_project/dbt_project.yml +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/examples/sample_dbt_project/macros/sample_execution_context.sql +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/examples/sample_dbt_project/models/marts/order_statuses.sql +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/examples/sample_dbt_project/models/marts/order_statuses.yml +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/examples/sample_dbt_project/profiles.yml +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/examples/sample_dbt_project/seeds/customers.csv +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/examples/sample_dbt_project/seeds/order_events.csv +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/examples/sample_dbt_project/seeds/orders.csv +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/examples/sample_dbt_project/seeds/products.csv +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/examples/sample_dbt_project/tests/slimtest_factories/customers.yml +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/examples/sample_dbt_project/tests/slimtest_factories/order_events.yml +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/examples/sample_dbt_project/tests/slimtest_factories/orders.yml +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/examples/sample_dbt_project/tests/slimtest_factories/products.yml +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/release-please-config.json +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/src/slimtest/__init__.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/src/slimtest/compile.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/src/slimtest/config.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/src/slimtest/dbt_project.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/src/slimtest/deep_merge.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/src/slimtest/expand.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/src/slimtest/factory.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/src/slimtest/manifest.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/src/slimtest/model_parser.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/src/slimtest/parametrize.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/src/slimtest/result_parser.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/src/slimtest/scenario.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/src/slimtest/schema.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/src/slimtest/selector.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/tests/__init__.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/tests/conftest.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/tests/test_compile.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/tests/test_config.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/tests/test_dbt_project.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/tests/test_deep_merge.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/tests/test_expand.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/tests/test_factory.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/tests/test_manifest.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/tests/test_model_parser.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/tests/test_parametrize.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/tests/test_result_parser.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/tests/test_scenario.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/tests/test_schema.py +0 -0
- {slimtest-0.2.0 → slimtest-0.3.0}/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,13 @@
|
|
|
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.0](https://github.com/Hisaaki-Kato/slimtest/compare/v0.2.0...v0.3.0) (2026-08-05)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* support dbt profile and target options ([#11](https://github.com/Hisaaki-Kato/slimtest/issues/11)) ([db0b542](https://github.com/Hisaaki-Kato/slimtest/commit/db0b5423735d3682a9907108f0e7e1dbf2e132d0))
|
|
11
|
+
|
|
5
12
|
## [0.2.0](https://github.com/Hisaaki-Kato/slimtest/compare/v0.1.1...v0.2.0) (2026-07-31)
|
|
6
13
|
|
|
7
14
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: slimtest
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
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
|
|
@@ -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])
|
|
@@ -119,7 +119,11 @@ class TestUnittestCommand:
|
|
|
119
119
|
def test_unittest_help(self):
|
|
120
120
|
result = _run("unittest", "--help")
|
|
121
121
|
assert result.exit_code == 0
|
|
122
|
-
|
|
122
|
+
output = _plain(result.output)
|
|
123
|
+
assert "--project-dir" in output
|
|
124
|
+
assert "--target" in output
|
|
125
|
+
assert "--profile" in output
|
|
126
|
+
assert "--profiles-dir" in output
|
|
123
127
|
|
|
124
128
|
def test_unittest_reports_summary_and_exits_zero_on_success(
|
|
125
129
|
self, monkeypatch, tmp_path: Path
|
|
@@ -161,10 +165,35 @@ class TestUnittestCommand:
|
|
|
161
165
|
],
|
|
162
166
|
summary=TestSummary(total=1, passed=1, failed=0, errored=0, skipped=0),
|
|
163
167
|
)
|
|
164
|
-
|
|
165
|
-
|
|
168
|
+
captured = {}
|
|
169
|
+
|
|
170
|
+
def fake_unittest_project(root, **kwargs):
|
|
171
|
+
captured["root"] = root
|
|
172
|
+
captured.update(kwargs)
|
|
173
|
+
return fake
|
|
174
|
+
|
|
175
|
+
monkeypatch.setattr("slimtest.cli.unittest_project", fake_unittest_project)
|
|
176
|
+
profiles_dir = tmp_path / "dbt-profiles"
|
|
177
|
+
result = _run(
|
|
178
|
+
"unittest",
|
|
179
|
+
"--project-dir",
|
|
180
|
+
str(tmp_path),
|
|
181
|
+
"--target",
|
|
182
|
+
"ci",
|
|
183
|
+
"--profile",
|
|
184
|
+
"analytics",
|
|
185
|
+
"--profiles-dir",
|
|
186
|
+
str(profiles_dir),
|
|
187
|
+
)
|
|
166
188
|
assert result.exit_code == 0
|
|
167
189
|
assert "1/1 passed" in _plain(result.output)
|
|
190
|
+
assert captured == {
|
|
191
|
+
"root": tmp_path,
|
|
192
|
+
"select": None,
|
|
193
|
+
"target": "ci",
|
|
194
|
+
"profile": "analytics",
|
|
195
|
+
"profiles_dir": profiles_dir,
|
|
196
|
+
}
|
|
168
197
|
|
|
169
198
|
def test_unittest_exits_one_when_a_test_fails(self, monkeypatch, tmp_path: Path):
|
|
170
199
|
from slimtest.compile import CompileResult
|
|
@@ -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.0}/examples/sample_dbt_project/macros/sample_execution_context.sql
RENAMED
|
File without changes
|
{slimtest-0.2.0 → slimtest-0.3.0}/examples/sample_dbt_project/models/marts/order_statuses.sql
RENAMED
|
File without changes
|
{slimtest-0.2.0 → slimtest-0.3.0}/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.0}/examples/sample_dbt_project/tests/slimtest_factories/customers.yml
RENAMED
|
File without changes
|
|
File without changes
|
{slimtest-0.2.0 → slimtest-0.3.0}/examples/sample_dbt_project/tests/slimtest_factories/orders.yml
RENAMED
|
File without changes
|
{slimtest-0.2.0 → slimtest-0.3.0}/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
|