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

TestGenerateCatalogWithExternalNodes #9456

Merged
merged 3 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions .changes/unreleased/Fixes-20240125-182243.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
kind: Fixes
body: Add TestGenerateCatalogWithExternalNodes, include empty nodes in node selection
during docs generate
time: 2024-01-25T18:22:43.253228-05:00
custom:
Author: michelleark
Issue: "9456"
1 change: 1 addition & 0 deletions core/dbt/task/docs/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ def get_node_selector(self) -> ResourceTypeSelector:
manifest=self.manifest,
previous_state=self.previous_state,
resource_types=EXECUTABLE_NODE_TYPES,
include_empty_nodes=True,
)

def get_catalog_results(
Expand Down
24 changes: 24 additions & 0 deletions tests/functional/docs/test_generate.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import pytest
from unittest import mock

from dbt.plugins.manifest import PluginNodes, ModelNodeArgs
from dbt.tests.util import run_dbt, get_manifest

sample_seed = """sample_num,sample_bool
Expand Down Expand Up @@ -87,6 +89,28 @@ def test_catalog_with_sources(self, project):
assert len(catalog.sources) == 2


class TestGenerateCatalogWithExternalNodes(TestBaseGenerate):
@mock.patch("dbt.plugins.get_plugin_manager")
def test_catalog_with_sources(self, get_plugin_manager, project):
project.run_sql("create table {}.external_model (id int)".format(project.test_schema))

run_dbt(["build"])

external_nodes = PluginNodes()
external_model_node = ModelNodeArgs(
name="external_model",
package_name="external_package",
identifier="external_model",
schema=project.test_schema,
database="dbt",
)
external_nodes.add_model(external_model_node)
get_plugin_manager.return_value.get_nodes.return_value = external_nodes
catalog = run_dbt(["docs", "generate"])

assert "model.external_package.external_model" in catalog.nodes


class TestGenerateSelectSource(TestBaseGenerate):
def test_select_source(self, project):
run_dbt(["build"])
Expand Down
Loading