diff --git a/test/integration/055_ref_override_tests/macros/ref_override_macro.sql b/test/integration/055_ref_override_tests/macros/ref_override_macro.sql deleted file mode 100644 index a4a85b50324..00000000000 --- a/test/integration/055_ref_override_tests/macros/ref_override_macro.sql +++ /dev/null @@ -1,4 +0,0 @@ --- Macro to override ref and always return the same result -{% macro ref(modelname) %} -{% do return(builtins.ref(modelname).replace_path(identifier='seed_2')) %} -{% endmacro %} \ No newline at end of file diff --git a/test/integration/055_ref_override_tests/models/ref_override.sql b/test/integration/055_ref_override_tests/models/ref_override.sql deleted file mode 100644 index 3bbf936ae2e..00000000000 --- a/test/integration/055_ref_override_tests/models/ref_override.sql +++ /dev/null @@ -1,3 +0,0 @@ -select - * -from {{ ref('seed_1') }} \ No newline at end of file diff --git a/test/integration/055_ref_override_tests/seeds/seed_1.csv b/test/integration/055_ref_override_tests/seeds/seed_1.csv deleted file mode 100644 index 4de2771bdac..00000000000 --- a/test/integration/055_ref_override_tests/seeds/seed_1.csv +++ /dev/null @@ -1,4 +0,0 @@ -a,b -1,2 -2,4 -3,6 \ No newline at end of file diff --git a/test/integration/055_ref_override_tests/seeds/seed_2.csv b/test/integration/055_ref_override_tests/seeds/seed_2.csv deleted file mode 100644 index eeadef9495c..00000000000 --- a/test/integration/055_ref_override_tests/seeds/seed_2.csv +++ /dev/null @@ -1,4 +0,0 @@ -a,b -6,2 -12,4 -18,6 \ No newline at end of file diff --git a/test/integration/055_ref_override_tests/test_ref_override.py b/test/integration/055_ref_override_tests/test_ref_override.py deleted file mode 100644 index 748379b447c..00000000000 --- a/test/integration/055_ref_override_tests/test_ref_override.py +++ /dev/null @@ -1,30 +0,0 @@ -from test.integration.base import DBTIntegrationTest, use_profile - - -class TestRefOverride(DBTIntegrationTest): - @property - def schema(self): - return "dbt_ref_override_055" - - @property - def project_config(self): - return { - 'config-version': 2, - 'seed-paths': ['seeds'], - "macro-paths": ["macros"], - 'seeds': { - 'quote_columns': False, - }, - } - - @property - def models(self): - return "models" - - @use_profile('postgres') - def test_postgres_ref_override(self): - self.run_dbt(['seed']) - self.run_dbt(['run']) - # We want it to equal seed_2 and not seed_1. If it's - # still pointing at seed_1 then the override hasn't worked. - self.assertTablesEqual('ref_override', 'seed_2') diff --git a/tests/adapter/dbt/tests/adapter/basic/test_table_mat.py b/tests/adapter/dbt/tests/adapter/basic/test_table_materialization.py similarity index 96% rename from tests/adapter/dbt/tests/adapter/basic/test_table_mat.py rename to tests/adapter/dbt/tests/adapter/basic/test_table_materialization.py index 7191195e7cc..875e0f1b66b 100644 --- a/tests/adapter/dbt/tests/adapter/basic/test_table_mat.py +++ b/tests/adapter/dbt/tests/adapter/basic/test_table_materialization.py @@ -80,7 +80,7 @@ def models(self): return {'materialized.sql': model_sql} def test_table_materialization_sort_dist_no_op(self, project): - # basic table mat test, sort and dist is not supported by postgres so the result table would still be same as input + # basic table materialization test, sort and dist is not supported by postgres so the result table would still be same as input # check seed results = run_dbt(["seed"]) diff --git a/tests/functional/ref_override/test_ref_override.py b/tests/functional/ref_override/test_ref_override.py new file mode 100644 index 00000000000..9a6b1def435 --- /dev/null +++ b/tests/functional/ref_override/test_ref_override.py @@ -0,0 +1,79 @@ +import pytest + +from dbt.tests.util import run_dbt, check_relations_equal +from dbt.tests.fixtures.project import write_project_files + + +models__ref_override_sql = """ +select + * +from {{ ref('seed_1') }} +""" + +macros__ref_override_macro_sql = """ +-- Macro to override ref and always return the same result +{% macro ref(modelname) %} +{% do return(builtins.ref(modelname).replace_path(identifier='seed_2')) %} +{% endmacro %} +""" + +seeds__seed_2_csv = """a,b +6,2 +12,4 +18,6""" + +seeds__seed_1_csv = """a,b +1,2 +2,4 +3,6""" + + +@pytest.fixture(scope="class") +def models(): + return {"ref_override.sql": models__ref_override_sql} + + +@pytest.fixture(scope="class") +def macros(): + return {"ref_override_macro.sql": macros__ref_override_macro_sql} + + +@pytest.fixture(scope="class") +def seeds(): + return {"seed_2.csv": seeds__seed_2_csv, "seed_1.csv": seeds__seed_1_csv} + + +@pytest.fixture(scope="class") +def project_files( + project_root, + models, + macros, + seeds, +): + write_project_files(project_root, "models", models) + write_project_files(project_root, "macros", macros) + write_project_files(project_root, "seeds", seeds) + + +class TestRefOverride: + @pytest.fixture(scope="class") + def project_config_update(self): + return { + "config-version": 2, + "seed-paths": ["seeds"], + "macro-paths": ["macros"], + "seeds": { + "quote_columns": False, + }, + } + + def test_ref_override( + self, + project, + ): + run_dbt(["seed"]) + run_dbt(["run"]) + + # We want it to equal seed_2 and not seed_1. If it's + # still pointing at seed_1 then the override hasn't worked. + check_relations_equal(project.adapter, ["ref_override", "seed_2"])