Skip to content

Commit

Permalink
TestGenerateCatalogWithExternalNodes (#9456)
Browse files Browse the repository at this point in the history
(cherry picked from commit 06e55bb)
  • Loading branch information
MichelleArk committed Jan 29, 2024
1 parent e9ee761 commit ccf5f24
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
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/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ def get_node_selector(self) -> ResourceTypeSelector:
manifest=self.manifest,
previous_state=self.previous_state,
resource_types=NodeType.executable(),
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

0 comments on commit ccf5f24

Please sign in to comment.