-
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.
migrate 034 integration test to functional (#6054)
* migrate 034 integration test to functional * formatting fixes * move to adapter directory * add extra args
- Loading branch information
1 parent
6de1d29
commit 0959979
Showing
3 changed files
with
44 additions
and
53 deletions.
There are no files selected for viewing
8 changes: 0 additions & 8 deletions
8
test/integration/034_changing_relation_type_tests/models/model.sql
This file was deleted.
Oops, something went wrong.
45 changes: 0 additions & 45 deletions
45
test/integration/034_changing_relation_type_tests/test_changing_relation_type.py
This file was deleted.
Oops, something went wrong.
44 changes: 44 additions & 0 deletions
44
tests/adapter/dbt/tests/adapter/relations/test_changing_relation_type.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,44 @@ | ||
|
||
|
||
from typing import List, Optional | ||
import pytest | ||
|
||
from dbt.tests.util import run_dbt | ||
|
||
|
||
_DEFAULT_CHANGE_RELATION_TYPE_MODEL = """ | ||
{{ config(materialized=var('materialized')) }} | ||
select '{{ var("materialized") }}' as materialization | ||
{% if var('materialized') == 'incremental' and is_incremental() %} | ||
where 'abc' != (select max(materialization) from {{ this }}) | ||
{% endif %} | ||
""" | ||
|
||
|
||
class BaseChangeRelationTypeValidator: | ||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return { | ||
"model_mc_modelface.sql": _DEFAULT_CHANGE_RELATION_TYPE_MODEL | ||
} | ||
|
||
def _run_and_check_materialization(self, materialization, extra_args: Optional[List] = None): | ||
run_args = ["run", '--vars', f'materialized: {materialization}'] | ||
if extra_args: | ||
run_args.extend(extra_args) | ||
results = run_dbt(run_args) | ||
assert results[0].node.config.materialized == materialization | ||
assert len(results) == 1 | ||
|
||
def test_changing_materialization_changes_relation_type(self, project): | ||
self._run_and_check_materialization('view') | ||
self._run_and_check_materialization('table') | ||
self._run_and_check_materialization('view') | ||
self._run_and_check_materialization('incremental') | ||
self._run_and_check_materialization('table', extra_args=['--full-refresh']) | ||
|
||
|
||
class TestChangeRelationTypes(BaseChangeRelationTypeValidator): | ||
pass |