Skip to content

Commit

Permalink
Merge pull request #359 from elementary-data/ele-900-fix-integration-…
Browse files Browse the repository at this point in the history
…tests-for-dbt-150

integration test: fix for dbt 1.5.0
  • Loading branch information
IDoneShaveIt authored May 17, 2023
2 parents d3b2eb3 + afc2aa4 commit 539119b
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion integration_tests/integration_tests/dbt_project.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import os
from pathlib import Path

import dbt.adapters.factory

dbt.adapters.factory.get_adapter = lambda config: config.adapter
Expand Down Expand Up @@ -27,6 +30,24 @@
disable_tracking()


def default_project_dir() -> Path:
if "DBT_PROJECT_DIR" in os.environ:
return Path(os.environ["DBT_PROJECT_DIR"]).resolve()
paths = list(Path.cwd().parents)
paths.insert(0, Path.cwd())
return next((x for x in paths if (x / "dbt_project.yml").exists()), Path.cwd())


def default_profiles_dir() -> Path:
if "DBT_PROFILES_DIR" in os.environ:
return Path(os.environ["DBT_PROFILES_DIR"]).resolve()
return Path.cwd() if (Path.cwd() / "profiles.yml").exists() else Path.home() / ".dbt"


DEFAULT_PROFILES_DIR = str(default_profiles_dir())
DEFAULT_PROJECT_DIR = str(default_project_dir())


class DbtProject:
def __init__(self, project_dir, target=None):
args = Args(project_dir=project_dir, target=target)
Expand Down Expand Up @@ -133,7 +154,8 @@ class Args(BaseModel):
Minimal mock to dbt config arguments
"""

project_dir: str
project_dir: str = DEFAULT_PROJECT_DIR
profiles_dir: str = DEFAULT_PROFILES_DIR
profile: str = None
target: Optional[str] = None
threads: Optional[int] = 1

0 comments on commit 539119b

Please sign in to comment.