-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include null checks in utils test base #7672
Merged
VersusFacit
merged 3 commits into
dbt-labs:main
from
sdebruyn:include-null-checks-in-base-utils-test
May 24, 2023
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: Under the Hood | ||
body: Include null checks in utils test base | ||
time: 2023-05-21T12:57:20.659726+02:00 | ||
custom: | ||
Author: sdebruyn | ||
Issue: "7670" |
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
34 changes: 34 additions & 0 deletions
34
tests/adapter/dbt/tests/adapter/utils/fixture_null_compare.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,34 @@ | ||
MODELS__TEST_MIXED_NULL_COMPARE_SQL = """ | ||
select | ||
1 as actual, | ||
null as expected | ||
""" | ||
|
||
|
||
MODELS__TEST_MIXED_NULL_COMPARE_YML = """ | ||
version: 2 | ||
models: | ||
- name: test_null_compare | ||
tests: | ||
- assert_equal: | ||
actual: actual | ||
expected: expected | ||
""" | ||
|
||
|
||
MODELS__TEST_NULL_COMPARE_SQL = """ | ||
select | ||
null as actual, | ||
null as expected | ||
""" | ||
|
||
|
||
MODELS__TEST_NULL_COMPARE_YML = """ | ||
version: 2 | ||
models: | ||
- name: test_null_compare | ||
tests: | ||
- assert_equal: | ||
actual: actual | ||
expected: expected | ||
""" |
40 changes: 40 additions & 0 deletions
40
tests/adapter/dbt/tests/adapter/utils/test_null_compare.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,40 @@ | ||
import pytest | ||
|
||
from dbt.tests.adapter.utils.base_utils import BaseUtils | ||
from dbt.tests.adapter.utils.fixture_null_compare import ( | ||
MODELS__TEST_MIXED_NULL_COMPARE_SQL, | ||
MODELS__TEST_MIXED_NULL_COMPARE_YML, | ||
MODELS__TEST_NULL_COMPARE_SQL, | ||
MODELS__TEST_NULL_COMPARE_YML, | ||
) | ||
from dbt.tests.util import run_dbt | ||
|
||
|
||
class BaseMixedNullCompare(BaseUtils): | ||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return { | ||
"test_mixed_null_compare.yml": MODELS__TEST_MIXED_NULL_COMPARE_SQL, | ||
"test_mixed_null_compare.sql": MODELS__TEST_MIXED_NULL_COMPARE_YML, | ||
} | ||
|
||
def test_build_assert_equal(self, project): | ||
run_dbt() | ||
run_dbt(["test"], expect_pass=False) | ||
|
||
|
||
class BaseNullCompare(BaseUtils): | ||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return { | ||
"test_null_compare.yml": MODELS__TEST_NULL_COMPARE_YML, | ||
"test_null_compare.sql": MODELS__TEST_NULL_COMPARE_SQL, | ||
} | ||
|
||
|
||
class TestMixedNullCompare(BaseNullCompare): | ||
pass | ||
|
||
|
||
class TestNullCompare(BaseNullCompare): | ||
pass |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really despise how the "absence of value is not equal to itself" definition is formally correct but does not reflect how anyone uses a Null in practice. Maybe we need a ANSI sequel patch while we're at it 😁