diff --git a/tests/dbt/test_docs.py b/tests/dbt/test_docs.py new file mode 100644 index 0000000000..7c21edb970 --- /dev/null +++ b/tests/dbt/test_docs.py @@ -0,0 +1,28 @@ +from pathlib import Path +import pytest + +from sqlmesh.core.config.model import ModelDefaultsConfig +from sqlmesh.dbt.context import DbtContext +from sqlmesh.dbt.manifest import ManifestHelper +from sqlmesh.dbt.profile import Profile + + +pytestmark = pytest.mark.dbt + + +@pytest.mark.xdist_group("dbt_manifest") +def test_docs_inline(): + project_path = Path("tests/fixtures/dbt/sushi_test") + profile = Profile.load(DbtContext(project_path)) + + helper = ManifestHelper( + project_path, + project_path, + "sushi", + profile.target, + model_defaults=ModelDefaultsConfig(start="2020-01-01"), + ) + # Inline description in yaml + assert helper.models()["waiters"].description == "waiters docs block" + # Docs block from .md file + assert helper.models()["top_waiters"].description == "description of top waiters" diff --git a/tests/fixtures/dbt/sushi_test/models/schema.yml b/tests/fixtures/dbt/sushi_test/models/schema.yml index a64ce3c1fc..ac99269207 100644 --- a/tests/fixtures/dbt/sushi_test/models/schema.yml +++ b/tests/fixtures/dbt/sushi_test/models/schema.yml @@ -2,6 +2,7 @@ version: 2 models: - name: top_waiters + description: description of top waiters columns: - name: waiter_id data_type: int @@ -18,6 +19,7 @@ models: warn_after: {count: 8, period: hour} error_after: {count: 9, period: hour} - name: waiters + description: '{{ doc("waiters") }}' - name: waiter_as_customer_by_day - name: waiter_revenue_by_day versions: diff --git a/tests/fixtures/dbt/sushi_test/models/waiters_doc_block.md b/tests/fixtures/dbt/sushi_test/models/waiters_doc_block.md new file mode 100644 index 0000000000..99d1582c91 --- /dev/null +++ b/tests/fixtures/dbt/sushi_test/models/waiters_doc_block.md @@ -0,0 +1,4 @@ +{% docs waiters %} +waiters docs block +{% enddocs %} +