Compare commits

...

4 Commits

Author SHA1 Message Date
Github Build Bot
5b0adfdff4 Add generated CLI API docs 2023-02-08 19:01:26 +00:00
Michelle Ark
4e99d16f9b Merge branch 'feature/click-cli' into arky/feature/click-cli/fix-log-path 2023-02-08 13:59:53 -05:00
Github Build Bot
2ef6ac34bc Add generated CLI API docs 2023-02-07 23:45:36 +00:00
Michelle Ark
2ed3fa7246 write logs to correct location in test 2023-02-07 18:21:03 -05:00
5 changed files with 13 additions and 12 deletions

View File

@@ -15,6 +15,8 @@ from dbt.contracts.project import UserConfig
from dbt.helper_types import WarnErrorOptions
from dbt.config.project import PartialProject
from dbt.exceptions import DbtProjectError
from dbt.cli.resolvers import default_project_dir
from pathlib import Path
if os.name != "nt":
# https://bugs.python.org/issue41567
@@ -132,8 +134,8 @@ class Flags:
# Default LOG_PATH from PROJECT_DIR, if available.
if getattr(self, "LOG_PATH", None) is None:
project_dir = getattr(self, "PROJECT_DIR", default_project_dir())
log_path = "logs"
project_dir = getattr(self, "PROJECT_DIR", None)
# If available, set LOG_PATH from log-path in dbt_project.yml
# Known limitations:
# 1. Using PartialProject here, so no jinja rendering of log-path.
@@ -147,8 +149,8 @@ class Flags:
log_path = str(partial.project_dict.get("log-path", log_path))
except DbtProjectError:
pass
object.__setattr__(self, "LOG_PATH", log_path)
# TODO should concatenation go here or on line 138?
object.__setattr__(self, "LOG_PATH", Path(project_dir) / log_path)
# Support console DO NOT TRACK initiave
object.__setattr__(

Binary file not shown.

View File

@@ -50,11 +50,10 @@ def set_from_args(args: Namespace, user_config):
# make a dummy context to get the flags, totally arbitrary
ctx = cli.make_context("run", ["run"])
flags = Flags(ctx, user_config)
for arg_name, args_param_value in vars(args).items():
args_param_value = convert_config(arg_name, args_param_value)
object.__setattr__(flags, arg_name.upper(), args_param_value)
object.__setattr__(flags, arg_name.lower(), args_param_value)
ctx.params[arg_name.lower()] = args_param_value
flags = Flags(ctx, user_config)
GLOBAL_FLAGS = flags # type: ignore

View File

@@ -356,8 +356,8 @@ def project_files(project_root, models, macros, snapshots, properties, seeds, te
# We have a separate logs dir for every test
@pytest.fixture(scope="class")
def logs_dir(request, prefix):
return os.path.join(request.config.rootdir, "logs", prefix)
def logs_dir(request, prefix, project_root):
return os.path.join(project_root, "logs")
# This fixture is for customizing tests that need overrides in adapter

View File

@@ -317,18 +317,18 @@ class TestProfileEnvVars:
"dbname": "dbt",
}
def test_profile_env_vars(self, project):
def test_profile_env_vars(self, project, monkeypatch):
# Initial run
os.environ["ENV_VAR_USER"] = "root"
os.environ["ENV_VAR_PASS"] = "password"
monkeypatch.setenv("ENV_VAR_USER", "root")
monkeypatch.setenv("ENV_VAR_PASS", "password")
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"
monkeypatch.setenv("ENV_VAR_USER", "fake_user")
# N.B. run_dbt_and_capture won't work here because FailedToConnectError ends the test entirely
with pytest.raises(FailedToConnectError):