From 6459e1276384be5bd2b1c956c5369ea3de60b981 Mon Sep 17 00:00:00 2001 From: Chenyu Li Date: Fri, 8 Apr 2022 14:54:47 -0600 Subject: [PATCH] add adapter method test (#95) --- tests/functional/adapter/test_basic.py | 4 ++++ .../macros/rename_named_relation.sql | 6 ----- .../adapter_methods_test/models/expected.sql | 3 --- .../adapter_methods_test/models/model.sql | 19 --------------- .../adapter_methods_test/models/upstream.sql | 1 - .../test_adapter_methods.py | 24 ------------------- .../tests/get_columns_in_relation.sql | 7 ------ 7 files changed, 4 insertions(+), 60 deletions(-) delete mode 100644 tests/integration/adapter_methods_test/macros/rename_named_relation.sql delete mode 100644 tests/integration/adapter_methods_test/models/expected.sql delete mode 100644 tests/integration/adapter_methods_test/models/model.sql delete mode 100644 tests/integration/adapter_methods_test/models/upstream.sql delete mode 100644 tests/integration/adapter_methods_test/test_adapter_methods.py delete mode 100644 tests/integration/adapter_methods_test/tests/get_columns_in_relation.sql diff --git a/tests/functional/adapter/test_basic.py b/tests/functional/adapter/test_basic.py index 728976cf0..d02c76c15 100644 --- a/tests/functional/adapter/test_basic.py +++ b/tests/functional/adapter/test_basic.py @@ -11,6 +11,7 @@ from dbt.tests.adapter.basic.test_generic_tests import BaseGenericTests from dbt.tests.adapter.basic.test_snapshot_check_cols import BaseSnapshotCheckCols from dbt.tests.adapter.basic.test_snapshot_timestamp import BaseSnapshotTimestamp +from dbt.tests.adapter.basic.test_adapter_methods import BaseAdapterMethod from dbt.tests.adapter.basic.files import seeds_base_csv, seeds_added_csv, seeds_newcolumns_csv @@ -77,3 +78,6 @@ def models(self): "newcolumns.csv": seeds_newcolumns_csv, "seeds.yml": schema_seed_added_yml, } + +class TestBaseAdapterMethod(BaseAdapterMethod): + pass \ No newline at end of file diff --git a/tests/integration/adapter_methods_test/macros/rename_named_relation.sql b/tests/integration/adapter_methods_test/macros/rename_named_relation.sql deleted file mode 100644 index 253e1e0ad..000000000 --- a/tests/integration/adapter_methods_test/macros/rename_named_relation.sql +++ /dev/null @@ -1,6 +0,0 @@ --- Macro to rename a relation -{% macro rename_named_relation(from_name, to_name) %} -{%- set from_relation = api.Relation.create(database=target.database, schema=target.schema, identifier=from_name, type='table') -%} -{%- set to_relation = api.Relation.create(database=target.database, schema=target.schema, identifier=to_name, type='table') -%} -{% do adapter.rename_relation(from_relation, to_relation) %} -{% endmacro %} \ No newline at end of file diff --git a/tests/integration/adapter_methods_test/models/expected.sql b/tests/integration/adapter_methods_test/models/expected.sql deleted file mode 100644 index ddebb5f5d..000000000 --- a/tests/integration/adapter_methods_test/models/expected.sql +++ /dev/null @@ -1,3 +0,0 @@ --- make sure this runs after 'model' --- {{ ref('model') }} -select 2 as id diff --git a/tests/integration/adapter_methods_test/models/model.sql b/tests/integration/adapter_methods_test/models/model.sql deleted file mode 100644 index bcf11d81c..000000000 --- a/tests/integration/adapter_methods_test/models/model.sql +++ /dev/null @@ -1,19 +0,0 @@ - -{% set upstream = ref('upstream') %} - -{% if execute %} - {# don't ever do any of this #} - {%- do adapter.drop_schema(upstream) -%} - {% set existing = adapter.get_relation(upstream.database, upstream.schema, upstream.identifier) %} - {% if existing is not none %} - {% do exceptions.raise_compiler_error('expected ' ~ ' to not exist, but it did') %} - {% endif %} - - {%- do adapter.create_schema(upstream) -%} - - {% set sql = create_view_as(upstream, 'select 2 as id') %} - {% do run_query(sql) %} -{% endif %} - - -select * from {{ upstream }} diff --git a/tests/integration/adapter_methods_test/models/upstream.sql b/tests/integration/adapter_methods_test/models/upstream.sql deleted file mode 100644 index 43258a714..000000000 --- a/tests/integration/adapter_methods_test/models/upstream.sql +++ /dev/null @@ -1 +0,0 @@ -select 1 as id diff --git a/tests/integration/adapter_methods_test/test_adapter_methods.py b/tests/integration/adapter_methods_test/test_adapter_methods.py deleted file mode 100644 index a261b0d9b..000000000 --- a/tests/integration/adapter_methods_test/test_adapter_methods.py +++ /dev/null @@ -1,24 +0,0 @@ -from tests.integration.base import DBTIntegrationTest, use_profile - - -class TestBaseCaching(DBTIntegrationTest): - @property - def schema(self): - return "caching" - - @property - def models(self): - return "models" - - @property - def project_config(self): - return { - 'config-version': 2, - 'test-paths': ['tests'] - } - - @use_profile('redshift') - def test_redshift_adapter_methods(self): - self.run_dbt(['compile']) # trigger any compile-time issues - self.run_dbt() - self.assertTablesEqual('model', 'expected') diff --git a/tests/integration/adapter_methods_test/tests/get_columns_in_relation.sql b/tests/integration/adapter_methods_test/tests/get_columns_in_relation.sql deleted file mode 100644 index 6507b52ec..000000000 --- a/tests/integration/adapter_methods_test/tests/get_columns_in_relation.sql +++ /dev/null @@ -1,7 +0,0 @@ -{% set columns = adapter.get_columns_in_relation(ref('model')) %} -{% set limit_query = 0 %} -{% if (columns | length) == 0 %} - {% set limit_query = 1 %} -{% endif %} - -select 1 as id limit {{ limit_query }}