Skip to content
Merged
Changes from all commits
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
46 changes: 25 additions & 21 deletions tests/functional/partial_parsing/test_pp_vars.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
import pytest
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorted imports aren't material to test changes, just improving the readability a bit.

import os
from pathlib import Path

from dbt.tests.util import run_dbt, write_file, run_dbt_and_capture, get_manifest
import pytest
from dbt.constants import SECRET_ENV_PREFIX
from dbt.exceptions import FailedToConnectError, ParsingError
from dbt.tests.util import get_manifest, run_dbt, run_dbt_and_capture, write_file

from tests.functional.partial_parsing.fixtures import (
model_color_sql,
env_var_model_sql,
env_var_schema_yml,
env_var_model_one_sql,
raw_customers_csv,
env_var_sources_yml,
test_color_sql,
env_var_schema2_yml,
env_var_schema3_yml,
env_var_macro_sql,
env_var_macros_yml,
env_var_model_test_yml,
people_sql,
env_var_metrics_yml,
env_var_model_one_sql,
env_var_model_sql,
env_var_model_test_yml,
env_var_schema2_yml,
env_var_schema3_yml,
env_var_schema_yml,
env_var_sources_yml,
model_color_sql,
model_one_sql,
people_sql,
raw_customers_csv,
test_color_sql,
)


from dbt.exceptions import ParsingError
from dbt.constants import SECRET_ENV_PREFIX
import os


os.environ["DBT_PP_TEST"] = "true"


Expand Down Expand Up @@ -325,14 +323,20 @@ def test_profile_env_vars(self, project):
os.environ["ENV_VAR_USER"] = "root"
os.environ["ENV_VAR_PASS"] = "password"

results = run_dbt(["run"])
run_dbt(["run"])
manifest = get_manifest(project.project_root)
env_vars_checksum = manifest.state_check.profile_env_vars_hash.checksum

# Change env_vars, the user doesn't exist, this should fail
os.environ["ENV_VAR_USER"] = "fake_user"
(results, log_output) = run_dbt_and_capture(["run"], expect_pass=False)

# N.B. run_dbt_and_capture won't work here because FailedToConnectError ends the test entirely
with pytest.raises(FailedToConnectError):
run_dbt(["run"], expect_pass=False)

log_output = Path(project.project_root, "logs", "dbt.log").read_text()
assert "env vars used in profiles.yml have changed" in log_output

manifest = get_manifest(project.project_root)
assert env_vars_checksum != manifest.state_check.profile_env_vars_hash.checksum

Expand Down