|
| 1 | +import os |
| 2 | + |
1 | 3 | import pytest
|
| 4 | +from dbt.tests.adapter.basic.expected_catalog import ( |
| 5 | + base_expected_catalog, |
| 6 | + expected_references_catalog, |
| 7 | + no_stats, |
| 8 | +) |
2 | 9 | from dbt.tests.adapter.basic.files import incremental_not_schema_change_sql
|
3 | 10 | from dbt.tests.adapter.basic.test_adapter_methods import BaseAdapterMethod
|
4 | 11 | from dbt.tests.adapter.basic.test_base import BaseSimpleMaterializations
|
| 12 | +from dbt.tests.adapter.basic.test_docs_generate import ( |
| 13 | + BaseDocsGenerate, |
| 14 | + BaseDocsGenReferences, |
| 15 | + ref_models__docs_md, |
| 16 | + ref_models__ephemeral_copy_sql, |
| 17 | + ref_models__schema_yml, |
| 18 | + ref_sources__schema_yml, |
| 19 | +) |
5 | 20 | from dbt.tests.adapter.basic.test_empty import BaseEmpty
|
6 | 21 | from dbt.tests.adapter.basic.test_ephemeral import BaseEphemeral
|
7 | 22 | from dbt.tests.adapter.basic.test_generic_tests import BaseGenericTests
|
@@ -74,3 +89,78 @@ class TestValidateConnectionSQLServer(BaseValidateConnection):
|
74 | 89 |
|
75 | 90 | class TestTableMatSQLServer(BaseTableMaterialization):
|
76 | 91 | pass
|
| 92 | + |
| 93 | + |
| 94 | +class TestDocsGenerateSQLServer(BaseDocsGenerate): |
| 95 | + @staticmethod |
| 96 | + @pytest.fixture(scope="class") |
| 97 | + def dbt_profile_target_update(): |
| 98 | + return {"schema_authorization": "{{ env_var('DBT_TEST_USER_1') }}"} |
| 99 | + |
| 100 | + @pytest.fixture(scope="class") |
| 101 | + def expected_catalog(self, project): |
| 102 | + return base_expected_catalog( |
| 103 | + project, |
| 104 | + role=os.getenv("DBT_TEST_USER_1"), |
| 105 | + id_type="int", |
| 106 | + text_type="varchar", |
| 107 | + time_type="datetime", |
| 108 | + view_type="VIEW", |
| 109 | + table_type="BASE TABLE", |
| 110 | + model_stats=no_stats(), |
| 111 | + ) |
| 112 | + |
| 113 | + |
| 114 | +class TestDocsGenReferencesSQLServer(BaseDocsGenReferences): |
| 115 | + @staticmethod |
| 116 | + @pytest.fixture(scope="class") |
| 117 | + def dbt_profile_target_update(): |
| 118 | + return {"schema_authorization": "{{ env_var('DBT_TEST_USER_1') }}"} |
| 119 | + |
| 120 | + @pytest.fixture(scope="class") |
| 121 | + def expected_catalog(self, project): |
| 122 | + return expected_references_catalog( |
| 123 | + project, |
| 124 | + role=os.getenv("DBT_TEST_USER_1"), |
| 125 | + id_type="int", |
| 126 | + text_type="varchar", |
| 127 | + time_type="datetime", |
| 128 | + bigint_type="int", |
| 129 | + view_type="VIEW", |
| 130 | + table_type="BASE TABLE", |
| 131 | + model_stats=no_stats(), |
| 132 | + ) |
| 133 | + |
| 134 | + @pytest.fixture(scope="class") |
| 135 | + def models(self): |
| 136 | + ref_models__ephemeral_summary_sql_no_order_by = """ |
| 137 | + {{ |
| 138 | + config( |
| 139 | + materialized = "table" |
| 140 | + ) |
| 141 | + }} |
| 142 | +
|
| 143 | + select first_name, count(*) as ct from {{ref('ephemeral_copy')}} |
| 144 | + group by first_name |
| 145 | + """ |
| 146 | + |
| 147 | + ref_models__view_summary_sql_no_order_by = """ |
| 148 | + {{ |
| 149 | + config( |
| 150 | + materialized = "view" |
| 151 | + ) |
| 152 | + }} |
| 153 | +
|
| 154 | + select first_name, ct from {{ref('ephemeral_summary')}} |
| 155 | + """ |
| 156 | + |
| 157 | + return { |
| 158 | + "schema.yml": ref_models__schema_yml, |
| 159 | + "sources.yml": ref_sources__schema_yml, |
| 160 | + # order by not allowed in VIEWS |
| 161 | + "view_summary.sql": ref_models__view_summary_sql_no_order_by, |
| 162 | + # order by not allowed in CTEs |
| 163 | + "ephemeral_summary.sql": ref_models__ephemeral_summary_sql_no_order_by, |
| 164 | + "ephemeral_copy.sql": ref_models__ephemeral_copy_sql, |
| 165 | + "docs.md": ref_models__docs_md, |
| 166 | + } |
0 commit comments