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

Merged
merged 5 commits into from
Jan 26, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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

This file was deleted.

This file was deleted.

This file was deleted.

61 changes: 61 additions & 0 deletions tests/functional/column_comments/test_column_comments.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import json
import pytest

from dbt.tests.util import run_dbt

_MODELS__MODEL_USING_QUOTE_UTIL = """
select 1 as {{ adapter.quote("2id") }}
"""

_PROPERTIES__QUOTE_MODEL = """
version: 2
models:
- name: quote_model
description: "model to test column quotes and comments"
columns:
- name: 2id
description: "XXX My description"
quote: true
"""


class TestColumnComment:
@pytest.fixture(scope="class")
def models(self):
return {"quote_model.sql": _MODELS__MODEL_USING_QUOTE_UTIL}

@pytest.fixture(scope="class")
def properties(self):
return {"properties.yml": _PROPERTIES__QUOTE_MODEL}

@pytest.fixture(scope="class")
def project_config_update(self):
return {
"models": {
"test": {
"materialized": "table",
"+persist_docs": {
"relation": True,
"columns": True,
},
}
}
}

@pytest.fixture(scope="class")
def run_has_comments(self, project):
def fixt():
run_dbt()
run_dbt(["docs", "generate"])
with open("target/catalog.json") as fp:
catalog_data = json.load(fp)
assert "nodes" in catalog_data
assert len(catalog_data["nodes"]) == 1
column_node = catalog_data["nodes"]["model.test.quote_model"]
column_comment = column_node["columns"]["2id"]["comment"]
assert column_comment.startswith("XXX")

return fixt

def test_postgres_comments(self, run_has_comments):
run_has_comments()