Skip to content

Commit

Permalink
parse vars in unit test utils (#313)
Browse files Browse the repository at this point in the history
* test against feature/click-cli core branch

* fix unit tests

* remove tests/integration tests

* done testing against feature branch

* test feature branch

* revert requs to use main branch

---------

Co-authored-by: Chenyu Li <chenyu.li@dbtlabs.com>
Co-authored-by: Ian Knox <ian.knox@dbtlabs.com>
  • Loading branch information
3 people authored Feb 10, 2023
1 parent b2de21b commit 3e956a6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/unit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ def profile_from_dict(profile, profile_name, cli_vars='{}'):
cli_vars = parse_cli_vars(cli_vars)

renderer = ProfileRenderer(cli_vars)

# in order to call dbt's internal profile rendering, we need to set the
# flags global. This is a bit of a hack, but it's the best way to do it.
from dbt.flags import set_from_args
from argparse import Namespace
set_from_args(Namespace(), None)
return Profile.from_raw_profile_info(
profile,
profile_name,
Expand Down Expand Up @@ -73,8 +79,12 @@ def project_from_dict(project, profile, packages=None, selectors=None, cli_vars=

def config_from_parts_or_dicts(project, profile, packages=None, selectors=None, cli_vars='{}'):
from dbt.config import Project, Profile, RuntimeConfig
from dbt.config.utils import parse_cli_vars
from copy import deepcopy

if not isinstance(cli_vars, dict):
cli_vars = parse_cli_vars(cli_vars)

if isinstance(project, Project):
profile_name = project.profile_name
else:
Expand Down

0 comments on commit 3e956a6

Please sign in to comment.