Skip to content

Commit

Permalink
Fix tests failing due to dbt-core changes (#60)
Browse files Browse the repository at this point in the history
* Update tests/unit/utils.py per dbt-core#4212

* Update docs_gen test for dbt-core#4154

* Update docs_gen test for dbt-core#4162
  • Loading branch information
jtcohen6 authored Nov 8, 2021
1 parent b2bf0f9 commit d92a7a2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
13 changes: 8 additions & 5 deletions tests/integration/docs_generate_tests/test_docs_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,8 +627,8 @@ def unrendered_tst_config(self, **updates):
def _verify_generic_macro_structure(self, manifest):
# just test a known global macro to avoid having to update this every
# time they change.
self.assertIn('macro.dbt.column_list', manifest['macros'])
macro = manifest['macros']['macro.dbt.column_list']
self.assertIn('macro.dbt.get_quoted_csv', manifest['macros'])
macro = manifest['macros']['macro.dbt.get_quoted_csv']
self.assertEqual(
set(macro),
{
Expand All @@ -645,7 +645,7 @@ def _verify_generic_macro_structure(self, manifest):
if k not in {'macro_sql'}
}
# Windows means we can't hard-code these.
helpers_path = Normalized('macros/materializations/helpers.sql')
helpers_path = Normalized('macros/materializations/models/incremental/column_helpers.sql')
root_path = Normalized(os.path.join(
self.dbt_core_install_root, 'include', 'global_project'
))
Expand All @@ -655,8 +655,8 @@ def _verify_generic_macro_structure(self, manifest):
'original_file_path': helpers_path,
'package_name': 'dbt',
'root_path': root_path,
'name': 'column_list',
'unique_id': 'macro.dbt.column_list',
'name': 'get_quoted_csv',
'unique_id': 'macro.dbt.get_quoted_csv',
'created_at': ANY,
'tags': [],
'resource_type': 'macro',
Expand Down Expand Up @@ -970,6 +970,7 @@ def expected_seeded_manifest(self, model_database=None, quote_model=False):
},
'deferred': False,
'description': '',
'file_key_name': 'models.model',
'fqn': ['test', 'not_null_model_id'],
'name': 'not_null_model_id',
'original_file_path': model_schema_yml_path,
Expand Down Expand Up @@ -1061,6 +1062,7 @@ def expected_seeded_manifest(self, model_database=None, quote_model=False):
},
'deferred': False,
'description': '',
'file_key_name': 'models.model',
'fqn': ['test', 'test_nothing_model_'],
'name': 'test_nothing_model_',
'original_file_path': model_schema_yml_path,
Expand Down Expand Up @@ -1107,6 +1109,7 @@ def expected_seeded_manifest(self, model_database=None, quote_model=False):
},
'deferred': False,
'description': '',
'file_key_name': 'models.model',
'fqn': ['test', 'unique_model_id'],
'name': 'unique_model_id',
'original_file_path': model_schema_yml_path,
Expand Down
19 changes: 11 additions & 8 deletions tests/unit/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Unit test utility functions.
Note that all imports should be inside the functions to avoid import/mocking
issues.
"""
Expand All @@ -11,11 +10,11 @@
import agate
import pytest
from dbt.dataclass_schema import ValidationError
from dbt.config.project import PartialProject


def normalize(path):
"""On windows, neither is enough on its own:
>>> normcase('C:\\documents/ALL CAPS/subdir\\..')
'c:\\documents\\all caps\\subdir\\..'
>>> normpath('C:\\documents/ALL CAPS/subdir\\..')
Expand Down Expand Up @@ -46,7 +45,7 @@ def profile_from_dict(profile, profile_name, cli_vars='{}'):
if not isinstance(cli_vars, dict):
cli_vars = parse_cli_vars(cli_vars)

renderer = ProfileRenderer(generate_base_context(cli_vars))
renderer = ProfileRenderer(cli_vars)
return Profile.from_raw_profile_info(
profile,
profile_name,
Expand All @@ -62,13 +61,18 @@ def project_from_dict(project, profile, packages=None, selectors=None, cli_vars=
if not isinstance(cli_vars, dict):
cli_vars = parse_cli_vars(cli_vars)

renderer = DbtProjectYamlRenderer(generate_target_context(profile, cli_vars))
renderer = DbtProjectYamlRenderer(profile, cli_vars)

project_root = project.pop('project-root', os.getcwd())

return Project.render_from_dict(
project_root, project, packages, selectors, renderer
)
partial = PartialProject.from_dicts(
project_root=project_root,
project_dict=project,
packages_dict=packages,
selectors_dict=selectors,
)
return partial.render(renderer)



def config_from_parts_or_dicts(project, profile, packages=None, selectors=None, cli_vars='{}'):
Expand Down Expand Up @@ -368,4 +372,3 @@ def replace_config(n, **kwargs):
config=n.config.replace(**kwargs),
unrendered_config=dict_replace(n.unrendered_config, **kwargs),
)

0 comments on commit d92a7a2

Please sign in to comment.