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

Migrate persist docs to an adapter zone variant. #416

Merged
merged 5 commits into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 2 additions & 2 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# install latest changes in dbt-core
# TODO: how to automate switching from develop to version branches?
git+https:/dbt-labs/dbt-core.git#egg=dbt-core&subdirectory=core
git+https:/dbt-labs/dbt-core.git#egg=dbt-tests-adapter&subdirectory=tests/adapter
git+https:/dbt-labs/dbt-core.git@f43cf8309968a5e0b473dc5e40fe1edb80cc1a56#egg=dbt-core&subdirectory=core
git+https:/dbt-labs/dbt-core.git@f43cf8309968a5e0b473dc5e40fe1edb80cc1a56#egg=dbt-tests-adapter&subdirectory=tests/adapter

black==22.8.0
click~=8.1.3
Expand Down
75 changes: 75 additions & 0 deletions tests/functional/adapter/test_persist_docs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import json
import os
import pytest

from dbt.tests.util import (
run_dbt
)

from dbt.tests.adapter.persist_docs.test_persist_docs import (
BasePersistDocs,
BasePersistDocsColumnMissing,
BasePersistDocsCommentOnQuotedColumn,
)


class TestPersistDocs(BasePersistDocs):
def _assert_common_comments(self, *comments):
for comment in comments:
assert '"with double quotes"' in comment
assert """'''abc123'''""" in comment
assert "\n" in comment
assert "Some [$]lbl[$] labeled [$]lbl[$] and [$][$] unlabeled [$][$] dollar-quoting" in comment
assert "/* comment */" in comment
if os.name == "nt":
assert "--\r\n" in comment or "--\n" in comment
else:
assert "--\n" in comment

def _assert_has_table_comments(self, table_node):
table_comment = table_node["metadata"]["comment"]
assert table_comment.startswith("Table model description")

table_id_comment = table_node["columns"]["ID"]["comment"]
assert table_id_comment.startswith("id Column description")

table_name_comment = table_node["columns"]["NAME"]["comment"]
assert table_name_comment.startswith("Some stuff here and then a call to")

self._assert_common_comments(table_comment, table_id_comment, table_name_comment)

def _assert_has_view_comments(
self, view_node, has_node_comments=True, has_column_comments=True
):
view_comment = view_node["metadata"]["comment"]
if has_node_comments:
assert view_comment.startswith("View model description")
self._assert_common_comments(view_comment)
else:
assert not view_comment

view_id_comment = view_node["columns"]["ID"]["comment"]
if has_column_comments:
assert view_id_comment.startswith("id Column description")
self._assert_common_comments(view_id_comment)
else:
assert not view_id_comment

view_name_comment = view_node["columns"]["NAME"]["comment"]
assert not view_name_comment


class TestPersistDocsColumnMissing(BasePersistDocsColumnMissing):
def test_missing_column(self, project):
run_dbt(["docs", "generate"])
with open("target/catalog.json") as fp:
catalog_data = json.load(fp)
assert "nodes" in catalog_data

table_node = catalog_data["nodes"]["model.test.missing_column"]
table_id_comment = table_node["columns"]["ID"]["comment"]
assert table_id_comment.startswith("test id column description")


class TestPersistDocsCommentOnQuotedColumn(BasePersistDocsCommentOnQuotedColumn):
pass

This file was deleted.

This file was deleted.

10 changes: 0 additions & 10 deletions tests/integration/persist_docs_tests/models/my_fun_docs.md

This file was deleted.

This file was deleted.

88 changes: 0 additions & 88 deletions tests/integration/persist_docs_tests/models/schema.yml

This file was deleted.

2 changes: 0 additions & 2 deletions tests/integration/persist_docs_tests/models/table_model.sql

This file was deleted.

2 changes: 0 additions & 2 deletions tests/integration/persist_docs_tests/models/view_model.sql

This file was deleted.

3 changes: 0 additions & 3 deletions tests/integration/persist_docs_tests/seeds/seed.csv

This file was deleted.

170 changes: 0 additions & 170 deletions tests/integration/persist_docs_tests/test_persist_docs.py

This file was deleted.