From 00559fd7a13aacccf28ea608657a0ac1aa60cc2b Mon Sep 17 00:00:00 2001 From: Jacob Beck Date: Thu, 30 May 2019 09:56:34 -0600 Subject: [PATCH] fix all the tests? --- .../schema_override_legacy_macros/schema.sql | 6 +++ .../schema_override_macros/schema.sql | 4 +- .../test_local_dependency.py | 48 ++++++++++++++++++- 3 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 test/integration/006_simple_dependency_test/schema_override_legacy_macros/schema.sql diff --git a/test/integration/006_simple_dependency_test/schema_override_legacy_macros/schema.sql b/test/integration/006_simple_dependency_test/schema_override_legacy_macros/schema.sql new file mode 100644 index 00000000000..b2456437d31 --- /dev/null +++ b/test/integration/006_simple_dependency_test/schema_override_legacy_macros/schema.sql @@ -0,0 +1,6 @@ + +{% macro generate_schema_name(schema_name) -%} + + {{ schema_name }}_{{ target.schema }}_macro + +{%- endmacro %} diff --git a/test/integration/006_simple_dependency_test/schema_override_macros/schema.sql b/test/integration/006_simple_dependency_test/schema_override_macros/schema.sql index b2456437d31..615c3fd3b1a 100644 --- a/test/integration/006_simple_dependency_test/schema_override_macros/schema.sql +++ b/test/integration/006_simple_dependency_test/schema_override_macros/schema.sql @@ -1,6 +1,6 @@ -{% macro generate_schema_name(schema_name) -%} +{% macro generate_schema_name(schema_name, node) -%} - {{ schema_name }}_{{ target.schema }}_macro + {{ schema_name }}_{{ node.schema }}_macro {%- endmacro %} diff --git a/test/integration/006_simple_dependency_test/test_local_dependency.py b/test/integration/006_simple_dependency_test/test_local_dependency.py index 27b7a9719a5..6c2a5ca20bd 100644 --- a/test/integration/006_simple_dependency_test/test_local_dependency.py +++ b/test/integration/006_simple_dependency_test/test_local_dependency.py @@ -7,8 +7,7 @@ import dbt.exceptions -class TestSimpleDependency(DBTIntegrationTest): - +class BaseDependencyTest(DBTIntegrationTest): @property def schema(self): return "local_dependency_006" @@ -17,6 +16,12 @@ def schema(self): def models(self): return "test/integration/006_simple_dependency_test/local_models" + def base_schema(self): + return self.unique_schema() + + def configured_schema(self): + return self.unique_schema() + '_configured' + @property def packages_config(self): return { @@ -27,6 +32,17 @@ def packages_config(self): ] } + +class TestSimpleDependency(BaseDependencyTest): + + @property + def schema(self): + return "local_dependency_006" + + @property + def models(self): + return "test/integration/006_simple_dependency_test/local_models" + def base_schema(self): return self.unique_schema() @@ -100,6 +116,34 @@ def test_postgres_local_dependency_out_of_date_no_check(self, mock_get): self.assertEqual(len(results), 3) +class TestDependencyWithLegacySchema(BaseDependencyTest): + @property + def project_config(self): + return { + 'macro-paths': ['test/integration/006_simple_dependency_test/schema_override_legacy_macros'], + 'models': { + 'schema': 'dbt_test', + } + } + + def base_schema(self): + return 'dbt_test_{}_macro'.format(self.unique_schema()) + + def configured_schema(self): + return 'configured_{}_macro'.format(self.unique_schema()) + + @use_profile('postgres') + @mock.patch('dbt.config.project.get_installed_version') + def test_postgres_local_dependency_out_of_date_no_check_no_strict(self, mock_get): + mock_get.return_value = dbt.semver.VersionSpecifier.from_version_string('0.0.1') + self.run_dbt(['deps']) + results = self.run_dbt(['run', '--no-version-check'], strict=False) + self.assertEqual(len(results), 3) + + with self.assertRaises(dbt.exceptions.CompilationException): + results = self.run_dbt(['run', '--no-version-check']) + + class TestSimpleDependencyHooks(DBTIntegrationTest): @property def schema(self):