99from dbt .tests .adapter .basic .test_docs_generate import (
1010 BaseDocsGenerate ,
1111 BaseDocsGenReferences ,
12- get_artifact ,
1312 ref_models__docs_md ,
1413 ref_models__ephemeral_copy_sql ,
1514 ref_models__schema_yml ,
1615 ref_sources__schema_yml ,
17- run_and_generate ,
18- verify_metadata ,
1916)
2017
2118
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-
5019class 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+
5125 @pytest .fixture (scope = "class" )
5226 def expected_catalog (self , project ):
5327 return base_expected_catalog (
5428 project ,
55- role = "dbo" ,
29+ role = os . getenv ( "DBT_TEST_USER_1" ) ,
5630 id_type = "int" ,
5731 text_type = "varchar" ,
5832 time_type = "datetime" ,
@@ -61,29 +35,18 @@ def expected_catalog(self, project):
6135 model_stats = no_stats (),
6236 )
6337
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-
8038
8139class 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+
8245 @pytest .fixture (scope = "class" )
8346 def expected_catalog (self , project ):
8447 return expected_references_catalog (
8548 project ,
86- role = "dbo" ,
49+ role = os . getenv ( "DBT_TEST_USER_1" ) ,
8750 id_type = "int" ,
8851 text_type = "varchar" ,
8952 time_type = "datetime" ,
@@ -126,7 +89,3 @@ def models(self):
12689 "ephemeral_copy.sql" : ref_models__ephemeral_copy_sql ,
12790 "docs.md" : ref_models__docs_md ,
12891 }
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