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

Ct 1827/064 column comments tests conversion #6766

Merged
merged 10 commits into from
Jan 31, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
import os
import pytest

from dbt.tests.util import (
run_dbt,
)
from dbt.tests.util import run_dbt

from tests.functional.persist_docs_tests.fixtures import (
from dbt.tests.adapter.persist_docs.fixtures import (
_DOCS__MY_FUN_DOCS,
_MODELS__MISSING_COLUMN,
_MODELS__MODEL_USING_QUOTE_UTIL,
Expand All @@ -20,7 +18,7 @@
)


class BasePersistDocsTest:
class BasePersistDocsBase:
@pytest.fixture(scope="class", autouse=True)
def setUp(self, project):
run_dbt(["seed"])
Expand Down Expand Up @@ -90,7 +88,7 @@ def _assert_has_view_comments(
assert view_name_comment is None


class TestPersistDocs(BasePersistDocsTest):
class BasePersistDocs(BasePersistDocsBase):
@pytest.fixture(scope="class")
def project_config_update(self):
return {
Expand Down Expand Up @@ -120,7 +118,7 @@ def test_has_comments_pglike(self, project):
self._assert_has_view_comments(no_docs_node, False, False)


class TestPersistDocsColumnMissing(BasePersistDocsTest):
class BasePersistDocsColumnMissing(BasePersistDocsBase):
@pytest.fixture(scope="class")
def project_config_update(self):
return {
Expand All @@ -141,7 +139,7 @@ def models(self):
def properties(self):
return {"schema.yml": _PROPERITES__SCHEMA_MISSING_COL}

def test_postgres_missing_column(self, project):
def test_missing_column(self, project):
run_dbt(["docs", "generate"])
with open("target/catalog.json") as fp:
catalog_data = json.load(fp)
Expand All @@ -152,7 +150,10 @@ def test_postgres_missing_column(self, project):
assert table_id_comment.startswith("test id column description")


class TestPersistDocsColumnComment:
class BasePersistDocsCommentOnQuotedColumn:
"""Covers edge case where column with comment must be quoted.
We set this using the `quote:` tag in the property file."""

@pytest.fixture(scope="class")
def models(self):
return {"quote_model.sql": _MODELS__MODEL_USING_QUOTE_UTIL}
Expand Down Expand Up @@ -190,5 +191,17 @@ def fixt():

return fixt

def test_postgres_comments(self, run_has_comments):
def test_quoted_column_comments(self, run_has_comments):
run_has_comments()


class TestPersistDocs(BasePersistDocs):
pass


class TestPersistDocsColumnMissing(BasePersistDocsColumnMissing):
pass


class TestPersistDocsCommentOnQuotedColumn(BasePersistDocsCommentOnQuotedColumn):
pass