-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
11 changed files
with
220 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Fixes | ||
body: Allow singular tests to be documented in properties.yml | ||
time: 2024-09-23T19:07:58.151069+01:00 | ||
custom: | ||
Author: aranke | ||
Issue: "9005" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
tests__my_singular_test_sql = """ | ||
with my_cte as ( | ||
select 1 as id, 'foo' as name | ||
union all | ||
select 2 as id, 'bar' as name | ||
) | ||
select * from my_cte | ||
""" | ||
|
||
tests__schema_yml = """ | ||
data_tests: | ||
- name: my_singular_test | ||
description: "{{ doc('my_singular_test_documentation') }}" | ||
config: | ||
error_if: ">10" | ||
meta: | ||
some_key: some_val | ||
""" | ||
|
||
tests__doc_block_md = """ | ||
{% docs my_singular_test_documentation %} | ||
Some docs from a doc block | ||
{% enddocs %} | ||
""" | ||
|
||
tests__invalid_name_schema_yml = """ | ||
data_tests: | ||
- name: my_double_test | ||
description: documentation, but make it double | ||
""" |
53 changes: 53 additions & 0 deletions
53
tests/functional/data_test_patch/test_singular_test_patch.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import os | ||
|
||
import pytest | ||
|
||
from dbt.tests.util import get_artifact, run_dbt, run_dbt_and_capture | ||
from tests.functional.data_test_patch.fixtures import ( | ||
tests__doc_block_md, | ||
tests__invalid_name_schema_yml, | ||
tests__my_singular_test_sql, | ||
tests__schema_yml, | ||
) | ||
|
||
|
||
class TestPatchSingularTest: | ||
@pytest.fixture(scope="class") | ||
def tests(self): | ||
return { | ||
"my_singular_test.sql": tests__my_singular_test_sql, | ||
"schema.yml": tests__schema_yml, | ||
"doc_block.md": tests__doc_block_md, | ||
} | ||
|
||
def test_compile(self, project): | ||
run_dbt(["compile"]) | ||
manifest = get_artifact(project.project_root, "target", "manifest.json") | ||
assert len(manifest["nodes"]) == 1 | ||
|
||
my_singular_test_node = manifest["nodes"]["test.test.my_singular_test"] | ||
assert my_singular_test_node["description"] == "Some docs from a doc block" | ||
assert my_singular_test_node["config"]["error_if"] == ">10" | ||
assert my_singular_test_node["config"]["meta"] == {"some_key": "some_val"} | ||
|
||
|
||
class TestPatchSingularTestInvalidName: | ||
@pytest.fixture(scope="class") | ||
def tests(self): | ||
return { | ||
"my_singular_test.sql": tests__my_singular_test_sql, | ||
"schema_with_invalid_name.yml": tests__invalid_name_schema_yml, | ||
} | ||
|
||
def test_compile(self, project): | ||
_, log_output = run_dbt_and_capture(["compile"]) | ||
|
||
file_path = ( | ||
"tests\\schema_with_invalid_name.yml" | ||
if os.name == "nt" | ||
else "tests/schema_with_invalid_name.yml" | ||
) | ||
assert ( | ||
f"Did not find matching node for patch with name 'my_double_test' in the 'data_tests' section of file '{file_path}'" | ||
in log_output | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters