Skip to content

Commit

Permalink
Merge pull request #160 from kokorin/feature/test-DbtYamlManager
Browse files Browse the repository at this point in the history
  • Loading branch information
z3z1ma authored Jun 15, 2024
2 parents 3a0d14e + a339798 commit 7348b65
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/dbt_osmosis/vendored/dbt_core_interface/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ class DbtConfiguration:
partial_parse: bool = False
# A required attribute for dbt, not used by our interface
dependencies: List[str] = field(default_factory=list)
which: str = None
DEBUG: bool = False
REQUIRE_RESOURCE_NAMES_WITHOUT_SPACES: bool = False

def __post_init__(self) -> None:
"""Post init hook to set single_threaded and remove target if not provided."""
Expand Down Expand Up @@ -332,6 +335,11 @@ def __init__(self, profile: str, target: str, **kwargs: Any) -> None:
self.macro: Optional[str] = kwargs.get("macro")
self.args: str = kwargs.get("args", "{}")
self.quiet: bool = kwargs.get("quiet", True)
self.defer_state: Path = kwargs.get("defer_state", None)
self.exclude_resource_types: List[str] = kwargs.get("exclude_resource_types", None)
self.selector: str = kwargs.get("selector", None)
self.write_json: bool = kwargs.get("write_json", False)
self.include_saved_query: bool = kwargs.get("include_saved_query", False)

@classmethod
def from_runtime_config(cls, config: RuntimeConfig, **kwargs: Any) -> "DbtTaskConfiguration":
Expand Down Expand Up @@ -888,7 +896,12 @@ def get_task_cls(self, typ: DbtCommand) -> Type["ManifestTask"]:

def get_task(self, typ: DbtCommand, args: DbtTaskConfiguration) -> "ManifestTask":
"""Get a dbt-core task by type."""
task = self.get_task_cls(typ)(args, self.config)
try:
# DBT 1.8 requires manifest as 2-nd positional argument
task = self.get_task_cls(typ)(args, self.config, self.manifest)
except Exception as e:
raise e
task = self.get_task_cls(typ)(args, self.config)
# Render this a no-op on this class instance so that the tasks `run`
# method plumbing will defer to our existing in memory manifest.
task.load_manifest = lambda *args, **kwargs: None # type: ignore
Expand Down
52 changes: 52 additions & 0 deletions tests/test_yaml_manager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import pytest

from dbt_osmosis.core.osmosis import DbtYamlManager


@pytest.fixture(scope="module")
def yaml_manager() -> DbtYamlManager:
return DbtYamlManager(project_dir="demo_duckdb", profiles_dir="demo_duckdb", dry_run=True)


def test_initialize_adapter(yaml_manager: DbtYamlManager):
yaml_manager.initialize_adapter()


def test_list(yaml_manager: DbtYamlManager):
yaml_manager.list()


def test_test(yaml_manager: DbtYamlManager):
yaml_manager.test()


def test_run(yaml_manager: DbtYamlManager):
yaml_manager.run()


def test_build(yaml_manager: DbtYamlManager):
yaml_manager.build()


def test_parse_project(yaml_manager: DbtYamlManager):
yaml_manager.parse_project()


def test_safe_parse_project(yaml_manager: DbtYamlManager):
yaml_manager.safe_parse_project()


def test_bootstrap_sources(yaml_manager: DbtYamlManager):
yaml_manager.bootstrap_sources()


def test_draft_project_structure_update_plan(yaml_manager: DbtYamlManager):
yaml_manager.draft_project_structure_update_plan()


def test_commit_project_restructure_to_disk(yaml_manager: DbtYamlManager):
yaml_manager.commit_project_restructure_to_disk()


def test_propagate_documentation_downstream(yaml_manager: DbtYamlManager):
yaml_manager.propagate_documentation_downstream()

0 comments on commit 7348b65

Please sign in to comment.