-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathtest_docs.py
93 lines (81 loc) · 2.67 KB
/
test_docs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import os
import pytest
from dbt.tests.adapter.basic.expected_catalog import (
base_expected_catalog,
expected_references_catalog,
no_stats,
)
from dbt.tests.adapter.basic.test_docs_generate import (
BaseDocsGenerate,
BaseDocsGenReferences,
ref_models__docs_md,
ref_models__ephemeral_copy_sql,
ref_models__schema_yml,
ref_sources__schema_yml,
)
# Assertion Failures
class TestDocsGenerateFabric(BaseDocsGenerate):
@staticmethod
@pytest.fixture(scope="class")
def dbt_profile_target_update():
return {"schema_authorization": "{{ env_var('DBT_TEST_USER_1') }}"}
@pytest.fixture(scope="class")
def expected_catalog(self, project):
return base_expected_catalog(
project,
role=os.getenv("DBT_TEST_USER_1"),
id_type="int",
text_type="varchar",
time_type="datetime2",
view_type="VIEW",
table_type="BASE TABLE",
model_stats=no_stats(),
)
# SQl errors
class TestDocsGenReferencesFabric(BaseDocsGenReferences):
@staticmethod
@pytest.fixture(scope="class")
def dbt_profile_target_update():
return {"schema_authorization": "{{ env_var('DBT_TEST_USER_1') }}"}
@pytest.fixture(scope="class")
def expected_catalog(self, project):
return expected_references_catalog(
project,
role=os.getenv("DBT_TEST_USER_1"),
id_type="int",
text_type="varchar",
time_type="datetime2",
bigint_type="int",
view_type="VIEW",
table_type="BASE TABLE",
model_stats=no_stats(),
)
@pytest.fixture(scope="class")
def models(self):
ref_models__ephemeral_summary_sql_no_order_by = """
{{
config(
materialized = "table"
)
}}
select first_name, count(*) as ct from {{ref('ephemeral_copy')}}
group by first_name
"""
ref_models__view_summary_sql_no_order_by = """
{{
config(
materialized = "view"
)
}}
select first_name, ct from {{ref('ephemeral_summary')}}
"""
return {
"schema.yml": ref_models__schema_yml,
"sources.yml": ref_sources__schema_yml,
# order by not allowed in VIEWS
"view_summary.sql": ref_models__view_summary_sql_no_order_by,
# order by not allowed in CTEs
"ephemeral_summary.sql": ref_models__ephemeral_summary_sql_no_order_by,
"ephemeral_copy.sql": ref_models__ephemeral_copy_sql,
"docs.md": ref_models__docs_md,
}