Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test_builtin_invocation_args_dict_function #6898

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions tests/functional/context_methods/test_builtin_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ def parse_json_logs(json_log_output):

def find_result_in_parsed_logs(parsed_logs, result_name):
return next(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Can we rewrite this as a loop instead?

(item for item in parsed_logs if result_name in item["info"].get("msg", "msg")),
(
item["data"]["msg"]
for item in parsed_logs
if result_name in item["data"].get("msg", "msg")
),
False,
)

Expand Down Expand Up @@ -105,26 +109,18 @@ def test_builtin_invocation_args_dict_function(self, project):

parsed_logs = parse_json_logs(log_output)
result = find_result_in_parsed_logs(parsed_logs, "invocation_result")

assert result

# Result is checked in two parts because profiles_dir is unique each test run
expected = "invocation_result: {'debug': True, 'log_format': 'json', 'write_json': True, 'use_colors': True, 'printer_width': 80, 'version_check': True, 'partial_parse': True, 'static_parser': True, 'profiles_dir': "
assert expected in str(result)
iknox-fa marked this conversation as resolved.
Show resolved Hide resolved

# The result should include a dictionary of all flags with default values that aren't None
expected = (
"'send_anonymous_usage_stats': False",
iknox-fa marked this conversation as resolved.
Show resolved Hide resolved
"'quiet': False",
"'no_print': False",
iknox-fa marked this conversation as resolved.
Show resolved Hide resolved
"'print': True",
"'cache_selected_only': False",
"'macro': 'validate_invocation'",
"'args': '{my_variable: test_variable}'",
iknox-fa marked this conversation as resolved.
Show resolved Hide resolved
"'args': {'my_variable': 'test_variable'}",
"'which': 'run-operation'",
"'rpc_method': 'run-operation'",
iknox-fa marked this conversation as resolved.
Show resolved Hide resolved
"'indirect_selection': 'eager'",
)
for element in expected:
assert element in str(result)
assert all(element in result for element in expected)

def test_builtin_dbt_metadata_envs_function(self, project, monkeypatch):
envs = {
Expand Down