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 #9457

Merged
merged 3 commits into from
Jan 31, 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
6 changes: 6 additions & 0 deletions .changes/unreleased/Under the Hood-20240129-141543.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Under the Hood
body: Add test for docs generate catalog with external nodes
time: 2024-01-29T14:15:43.562681-05:00
custom:
Author: michelleark
Issue: "9481"
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
import json

Expand All @@ -25,3 +27,25 @@ def test_generate_empty_catalog(self, project):
assert catalog["nodes"] == {}, "nodes should be empty"
assert catalog["sources"] == {}, "sources should be empty"
assert catalog["errors"] is None, "errors should be null"


class TestGenerateCatalogWithExternalNodes(TestGenerate):
@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
Loading