9
9
from dbt .tests .adapter .basic .test_docs_generate import (
10
10
BaseDocsGenerate ,
11
11
BaseDocsGenReferences ,
12
- get_artifact ,
13
12
ref_models__docs_md ,
14
13
ref_models__ephemeral_copy_sql ,
15
14
ref_models__schema_yml ,
16
15
ref_sources__schema_yml ,
17
- run_and_generate ,
18
- verify_metadata ,
19
16
)
20
17
21
18
22
- def verify_catalog (project , expected_catalog , start_time , ignore_owner ):
23
- # get the catalog.json
24
- catalog_path = os .path .join (project .project_root , "target" , "catalog.json" )
25
- assert os .path .exists (catalog_path )
26
- catalog = get_artifact (catalog_path )
27
-
28
- # verify the catalog
29
- assert set (catalog ) == {"errors" , "metadata" , "nodes" , "sources" }
30
- verify_metadata (
31
- catalog ["metadata" ],
32
- "https://schemas.getdbt.com/dbt/catalog/v1.json" ,
33
- start_time ,
34
- )
35
- assert not catalog ["errors" ]
36
- for key in "nodes" , "sources" :
37
- for unique_id , expected_node in expected_catalog [key ].items ():
38
- found_node = catalog [key ][unique_id ]
39
- for node_key in expected_node :
40
- assert node_key in found_node
41
-
42
- if node_key == "metadata" and ignore_owner :
43
- expected_node [node_key ]["owner" ] = found_node [node_key ]["owner" ]
44
-
45
- assert (
46
- found_node [node_key ] == expected_node [node_key ]
47
- ), f"Key '{ node_key } ' in '{ unique_id } ' did not match"
48
-
49
-
50
19
class TestDocsGenerateSQLServer (BaseDocsGenerate ):
20
+ @staticmethod
21
+ @pytest .fixture (scope = "class" )
22
+ def dbt_profile_target_update ():
23
+ return {"schema_authorization" : "{{ env_var('DBT_TEST_USER_1') }}" }
24
+
51
25
@pytest .fixture (scope = "class" )
52
26
def expected_catalog (self , project ):
53
27
return base_expected_catalog (
54
28
project ,
55
- role = "dbo" ,
29
+ role = os . getenv ( "DBT_TEST_USER_1" ) ,
56
30
id_type = "int" ,
57
31
text_type = "varchar" ,
58
32
time_type = "datetime" ,
@@ -61,29 +35,18 @@ def expected_catalog(self, project):
61
35
model_stats = no_stats (),
62
36
)
63
37
64
- # Test "--no-compile" flag works and produces no manifest.json
65
- def test_run_and_generate_no_compile (self , project , expected_catalog , is_azure : bool ):
66
- start_time = run_and_generate (project , ["--no-compile" ])
67
- assert not os .path .exists (os .path .join (project .project_root , "target" , "manifest.json" ))
68
- verify_catalog (project , expected_catalog , start_time , is_azure )
69
-
70
- # Test generic "docs generate" command
71
- def test_run_and_generate (self , project , expected_catalog , is_azure : bool ):
72
- start_time = run_and_generate (project )
73
- verify_catalog (project , expected_catalog , start_time , is_azure )
74
-
75
- # Check that assets have been copied to the target directory for use in the docs html page
76
- assert os .path .exists (os .path .join ("." , "target" , "assets" ))
77
- assert os .path .exists (os .path .join ("." , "target" , "assets" , "lorem-ipsum.txt" ))
78
- assert not os .path .exists (os .path .join ("." , "target" , "non-existent-assets" ))
79
-
80
38
81
39
class TestDocsGenReferencesSQLServer (BaseDocsGenReferences ):
40
+ @staticmethod
41
+ @pytest .fixture (scope = "class" )
42
+ def dbt_profile_target_update ():
43
+ return {"schema_authorization" : "{{ env_var('DBT_TEST_USER_1') }}" }
44
+
82
45
@pytest .fixture (scope = "class" )
83
46
def expected_catalog (self , project ):
84
47
return expected_references_catalog (
85
48
project ,
86
- role = "dbo" ,
49
+ role = os . getenv ( "DBT_TEST_USER_1" ) ,
87
50
id_type = "int" ,
88
51
text_type = "varchar" ,
89
52
time_type = "datetime" ,
@@ -126,7 +89,3 @@ def models(self):
126
89
"ephemeral_copy.sql" : ref_models__ephemeral_copy_sql ,
127
90
"docs.md" : ref_models__docs_md ,
128
91
}
129
-
130
- def test_references (self , project , expected_catalog , is_azure : bool ):
131
- start_time = run_and_generate (project )
132
- verify_catalog (project , expected_catalog , start_time , is_azure )
0 commit comments