Skip to content

Commit eed0daf

Browse files
committed
chore: testing docs additions
- tests dbt docs blocks
1 parent 3507a19 commit eed0daf

File tree

6 files changed

+66
-16
lines changed

6 files changed

+66
-16
lines changed

examples/sushi_dbt/models/waiter_as_customer_by_day.sql

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{% docs waiters %}
2+
waiters docs block
3+
{% enddocs %}
4+

test_descriptions.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env python3
2+
from pathlib import Path
3+
from sqlmesh.dbt.context import DbtContext
4+
5+
# Initialize the context for the sushi_test project
6+
context = DbtContext(project_root=Path("tests/fixtures/dbt/sushi_test"))
7+
8+
# Get the manifest
9+
manifest = context._manifest
10+
if manifest and hasattr(manifest, '_manifest'):
11+
nodes = manifest._manifest.nodes
12+
13+
print("=== Checking node descriptions ===")
14+
for node_name, node in nodes.items():
15+
if 'top_waiters' in node_name or ('waiters' in node_name and 'waiter_' not in node_name):
16+
print(f'\nNode: {node_name}')
17+
print(f' Has description attr: {hasattr(node, "description")}')
18+
if hasattr(node, "description"):
19+
print(f' description value: {node.description!r}')
20+
21+
if hasattr(node, 'to_dict'):
22+
node_dict = node.to_dict()
23+
print(f' description in dict: {"description" in node_dict}')
24+
if "description" in node_dict:
25+
print(f' dict description value: {node_dict["description"]!r}')
26+
27+
if hasattr(node, 'config'):
28+
config_dict = node.config.to_dict()
29+
print(f' description in config: {"description" in config_dict}')
30+
if "description" in config_dict:
31+
print(f' config description value: {config_dict["description"]!r}')
32+
33+
# Now check the loaded models
34+
print("\n=== Checking loaded models ===")
35+
models = manifest.models() if manifest else {}
36+
for name, model in models.items():
37+
if name == 'top_waiters' or name == 'waiters':
38+
print(f'\nModel: {name}')
39+
print(f' description: {model.description!r}')

tests/dbt/test_docs.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from __future__ import annotations
2+
3+
import pytest
4+
5+
from sqlmesh.dbt.project import Project
6+
7+
pytestmark = pytest.mark.dbt
8+
9+
10+
def test_docs_inline(sushi_test_project: Project):
11+
# Inline description in yaml
12+
top_waiters = sushi_test_project.context._models["top_waiters"]
13+
assert top_waiters.description == "description of top waiters"
14+
15+
# Docs block from .md file
16+
waiters = sushi_test_project.context._models["waiters"]
17+
assert waiters.description == "waiters docs block"

tests/fixtures/dbt/sushi_test/models/schema.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ version: 2
22

33
models:
44
- name: top_waiters
5+
description: description of top waiters
56
columns:
67
- name: waiter_id
78
data_type: int
@@ -18,6 +19,7 @@ models:
1819
warn_after: {count: 8, period: hour}
1920
error_after: {count: 9, period: hour}
2021
- name: waiters
22+
description: '{{ doc("waiters") }}'
2123
- name: waiter_as_customer_by_day
2224
- name: waiter_revenue_by_day
2325
versions:
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{% docs waiters %}
2+
waiters docs block
3+
{% enddocs %}
4+

0 commit comments

Comments
 (0)