Skip to content

Commit

Permalink
parse vars in unit test utils (#518)
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

* Testing click cli branch

* fix unittest

* Done testing click branch, working properly

---------

Co-authored-by: Stu Kilgore <[email protected]>
Co-authored-by: Chenyu Li <[email protected]>
  • Loading branch information
3 people authored Feb 10, 2023
1 parent a7af39a commit 34b0a77
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/unit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,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 All @@ -54,7 +60,6 @@ def profile_from_dict(profile, profile_name, cli_vars='{}'):


def project_from_dict(project, profile, packages=None, selectors=None, cli_vars='{}'):
from dbt.context.target import generate_target_context
from dbt.config import Project
from dbt.config.renderer import DbtProjectYamlRenderer
from dbt.config.utils import parse_cli_vars
Expand All @@ -78,6 +83,9 @@ 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 copy import deepcopy
from dbt.config.utils import parse_cli_vars
if not isinstance(cli_vars, dict):
cli_vars = parse_cli_vars(cli_vars)

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

0 comments on commit 34b0a77

Please sign in to comment.