-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dbt-core 1.3 upgrade: New functional adapter tests (#63)
### Summary dbt-core 1.3 upgrade: New functional adapter tests ### Description Implement: - BaseIncrementalNotSchemaChange - BaseTypeBoolean - BaseCurrentTimestampNaive - BaseConcurrency ### Related Issue #45
- Loading branch information
Showing
11 changed files
with
282 additions
and
195 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,33 @@ | ||
import pytest | ||
from tests.functional.adapter.utils.test_utils import DATALAKE | ||
|
||
# This ensures the schema works with our datalake | ||
@pytest.fixture(scope="class") | ||
def unique_schema(request, prefix) -> str: | ||
test_file = request.module.__name__ | ||
# We only want the last part of the name | ||
test_file = test_file.split(".")[-1] | ||
unique_schema = f"{prefix}_{test_file}" | ||
return unique_schema | ||
|
||
|
||
# Override this fixture to set root_path=schema | ||
@pytest.fixture(scope="class") | ||
def dbt_profile_data(unique_schema, dbt_profile_target, profiles_config_update): | ||
profile = { | ||
"config": {"send_anonymous_usage_stats": False}, | ||
"test": { | ||
"outputs": { | ||
"default": {}, | ||
}, | ||
"target": "default", | ||
}, | ||
} | ||
target = dbt_profile_target | ||
target["schema"] = unique_schema | ||
target["root_path"] = f"{DATALAKE}.{unique_schema}" | ||
profile["test"]["outputs"]["default"] = target | ||
|
||
if profiles_config_update: | ||
profile.update(profiles_config_update) | ||
return profile |
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 |
---|---|---|
|
@@ -40,7 +40,6 @@ | |
schema=var('alternate_schema') | ||
) | ||
}} | ||
select * from {{ ref('seed') }} | ||
""" | ||
|
||
|
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,102 @@ | ||
import pytest | ||
from dbt.tests.adapter.concurrency.test_concurrency import ( | ||
BaseConcurrency, | ||
models__dep_sql, | ||
models__view_with_conflicting_cascade_sql, | ||
models__skip_sql, | ||
seeds__update_csv, | ||
) | ||
from dbt.tests.util import ( | ||
check_relations_equal, | ||
check_table_does_not_exist, | ||
rm_file, | ||
run_dbt, | ||
run_dbt_and_capture, | ||
write_file, | ||
) | ||
from tests.fixtures.profiles import unique_schema, dbt_profile_data | ||
|
||
models__invalid_sql = """ | ||
{{ | ||
config( | ||
materialized = "table" | ||
) | ||
}} | ||
select a_field_that_does_not_exist from {{ ref(var('seed_name', 'seed')) }} | ||
""" | ||
|
||
models__table_a_sql = """ | ||
{{ | ||
config( | ||
materialized = "table" | ||
) | ||
}} | ||
select * from {{ ref(var('seed_name', 'seed')) }} | ||
""" | ||
|
||
models__table_b_sql = """ | ||
{{ | ||
config( | ||
materialized = "table" | ||
) | ||
}} | ||
select * from {{ ref(var('seed_name', 'seed')) }} | ||
""" | ||
|
||
models__view_model_sql = """ | ||
{{ | ||
config( | ||
materialized = "view" | ||
) | ||
}} | ||
select * from {{ ref(var('seed_name', 'seed')) }} | ||
""" | ||
|
||
|
||
class TestConcurrency(BaseConcurrency): | ||
# invalid_sql, table_a_sql, table_b_sql and view_model_sql | ||
# are overriden to ensure the seed file path is correct. | ||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return { | ||
"invalid.sql": models__invalid_sql, | ||
"table_a.sql": models__table_a_sql, | ||
"table_b.sql": models__table_b_sql, | ||
"view_model.sql": models__view_model_sql, | ||
"dep.sql": models__dep_sql, | ||
"view_with_conflicting_cascade.sql": models__view_with_conflicting_cascade_sql, | ||
"skip.sql": models__skip_sql, | ||
} | ||
|
||
def test_concurrency(self, project): | ||
run_dbt(["seed", "--select", "seed"]) | ||
results = run_dbt(["run"], expect_pass=False) | ||
assert len(results) == 7 | ||
check_relations_equal(project.adapter, ["seed", "view_model"]) | ||
check_relations_equal(project.adapter, ["seed", "dep"]) | ||
check_relations_equal(project.adapter, ["seed", "table_a"]) | ||
check_relations_equal(project.adapter, ["seed", "table_b"]) | ||
check_table_does_not_exist(project.adapter, "invalid") | ||
check_table_does_not_exist(project.adapter, "skip") | ||
|
||
rm_file(project.project_root, "seeds", "seed.csv") | ||
write_file(seeds__update_csv, project.project_root, "seeds", "seed.csv") | ||
|
||
results, output = run_dbt_and_capture(["run"], expect_pass=False) | ||
assert len(results) == 7 | ||
check_relations_equal(project.adapter, ["seed", "view_model"]) | ||
check_relations_equal(project.adapter, ["seed", "dep"]) | ||
check_relations_equal(project.adapter, ["seed", "table_a"]) | ||
check_relations_equal(project.adapter, ["seed", "table_b"]) | ||
check_table_does_not_exist(project.adapter, "invalid") | ||
check_table_does_not_exist(project.adapter, "skip") | ||
|
||
assert "PASS=5 WARN=0 ERROR=1 SKIP=1 TOTAL=7" in 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from dbt.tests.adapter.utils.data_types.test_type_boolean import BaseTypeBoolean | ||
from tests.fixtures.profiles import unique_schema, dbt_profile_data | ||
|
||
|
||
class TestTypeBoolean(BaseTypeBoolean): | ||
pass |
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,8 @@ | ||
from dbt.tests.adapter.utils.test_current_timestamp import ( | ||
BaseCurrentTimestampNaive, | ||
) | ||
from tests.fixtures.profiles import unique_schema, dbt_profile_data | ||
|
||
|
||
class TestCurrentTimestampNaive(BaseCurrentTimestampNaive): | ||
pass |