Skip to content
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

migrate 034 integration test to functional #6054

Merged
merged 4 commits into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fun model name

}

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