From b516083aa64d4fcbceecbe489f8d3c82e3099e70 Mon Sep 17 00:00:00 2001 From: Ben King <9087625+benfdking@users.noreply.github.com> Date: Mon, 25 Aug 2025 16:39:30 +0200 Subject: [PATCH 1/3] chore: testing docs additions - tests dbt docs blocks --- tests/dbt/test_docs.py | 15 +++++++++++++++ tests/fixtures/dbt/sushi_test/models/schema.yml | 2 ++ .../dbt/sushi_test/models/waiters_doc_block.md | 4 ++++ 3 files changed, 21 insertions(+) create mode 100644 tests/dbt/test_docs.py create mode 100644 tests/fixtures/dbt/sushi_test/models/waiters_doc_block.md diff --git a/tests/dbt/test_docs.py b/tests/dbt/test_docs.py new file mode 100644 index 0000000000..1fdae47b64 --- /dev/null +++ b/tests/dbt/test_docs.py @@ -0,0 +1,15 @@ +import pytest + +from sqlmesh.dbt.project import Project + +pytestmark = pytest.mark.dbt + + +def test_docs_inline(sushi_test_project: Project): + # Inline description in yaml + top_waiters = sushi_test_project.context._models["top_waiters"] + assert top_waiters.description == "description of top waiters" + + # Docs block from .md file + waiters = sushi_test_project.context._models["waiters"] + assert waiters.description == "waiters docs block" 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 %} + From 25f71e82d9fb58ad44b9d9d78ffb51e28877d757 Mon Sep 17 00:00:00 2001 From: Ben <9087625+benfdking@users.noreply.github.com> Date: Tue, 26 Aug 2025 13:45:23 +0200 Subject: [PATCH 2/3] Update tests/dbt/test_docs.py Co-authored-by: Themis Valtinos <73662635+themisvaltinos@users.noreply.github.com> --- tests/dbt/test_docs.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/dbt/test_docs.py b/tests/dbt/test_docs.py index 1fdae47b64..fff0f92e33 100644 --- a/tests/dbt/test_docs.py +++ b/tests/dbt/test_docs.py @@ -5,7 +5,22 @@ pytestmark = pytest.mark.dbt -def test_docs_inline(sushi_test_project: Project): +@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" + + assert helper.models()["top_waiters"].description == "description of top waiters" # Inline description in yaml top_waiters = sushi_test_project.context._models["top_waiters"] assert top_waiters.description == "description of top waiters" From ea01ab1e9e06afaca1bb10ab6bc3cca7c53ec218 Mon Sep 17 00:00:00 2001 From: Ben King <9087625+benfdking@users.noreply.github.com> Date: Tue, 26 Aug 2025 14:23:30 +0200 Subject: [PATCH 3/3] temp --- tests/dbt/test_docs.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/tests/dbt/test_docs.py b/tests/dbt/test_docs.py index fff0f92e33..7c21edb970 100644 --- a/tests/dbt/test_docs.py +++ b/tests/dbt/test_docs.py @@ -1,6 +1,11 @@ +from pathlib import Path import pytest -from sqlmesh.dbt.project import Project +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 @@ -19,12 +24,5 @@ def test_docs_inline(): ) # Inline description in yaml assert helper.models()["waiters"].description == "waiters docs block" - - assert helper.models()["top_waiters"].description == "description of top waiters" - # Inline description in yaml - top_waiters = sushi_test_project.context._models["top_waiters"] - assert top_waiters.description == "description of top waiters" - # Docs block from .md file - waiters = sushi_test_project.context._models["waiters"] - assert waiters.description == "waiters docs block" + assert helper.models()["top_waiters"].description == "description of top waiters"