@@ -29,6 +29,7 @@ def test_tests_get_unique_names(tmp_path: Path, create_empty_project) -> None:
2929 # Create schema.yml with:
3030 # 1. Same test on model and source, both with/without custom test name
3131 # 2. Same test on same model with different args, both with/without custom test name
32+ # 3. Versioned model with tests (both built-in and custom named)
3233 schema_yaml = {
3334 "version" : 2 ,
3435 "sources" : [
@@ -81,24 +82,61 @@ def test_tests_get_unique_names(tmp_path: Path, create_empty_project) -> None:
8182 ],
8283 },
8384 ],
84- }
85+ },
86+ {
87+ "name" : "versioned_model" ,
88+ "columns" : [
89+ {
90+ "name" : "id" ,
91+ "data_tests" : [
92+ {"not_null" : {}},
93+ {"not_null" : {"name" : "custom_versioned_notnull" }},
94+ ],
95+ },
96+ {
97+ "name" : "amount" ,
98+ "data_tests" : [
99+ {"accepted_values" : {"values" : ["low" , "high" ]}},
100+ ],
101+ },
102+ ],
103+ "versions" : [
104+ {"v" : 1 },
105+ {"v" : 2 },
106+ ],
107+ },
85108 ],
86109 }
87110
88111 schema_file = model_dir / "schema.yml"
89112 with open (schema_file , "w" , encoding = "utf-8" ) as f :
90113 yaml .dump (schema_yaml , f )
91114
115+ # Create versioned model files
116+ versioned_model_v1_file = model_dir / "versioned_model_v1.sql"
117+ with open (versioned_model_v1_file , "w" , encoding = "utf-8" ) as f :
118+ f .write ("SELECT 1 as id, 'low' as amount" )
119+
120+ versioned_model_v2_file = model_dir / "versioned_model_v2.sql"
121+ with open (versioned_model_v2_file , "w" , encoding = "utf-8" ) as f :
122+ f .write ("SELECT 1 as id, 'low' as amount" )
123+
92124 context = Context (paths = project_dir )
93125
94126 all_audit_names = list (context ._audits .keys ()) + list (context ._standalone_audits .keys ())
95127 assert sorted (all_audit_names ) == [
96128 "local.accepted_values_my_model_status__value1__value2" ,
97129 "local.accepted_values_my_model_status__value1__value2__value3" ,
130+ "local.accepted_values_versioned_model_v1_amount__low__high" ,
131+ "local.accepted_values_versioned_model_v2_amount__low__high" ,
98132 "local.custom_accepted_values_name_my_model_status__value1__value2" ,
99133 "local.custom_accepted_values_name_my_model_status__value1__value2__value3" ,
100134 "local.custom_notnull_name_my_model_id" ,
135+ "local.custom_versioned_notnull_versioned_model_v1_id" ,
136+ "local.custom_versioned_notnull_versioned_model_v2_id" ,
101137 "local.not_null_my_model_id" ,
138+ "local.not_null_versioned_model_v1_id" ,
139+ "local.not_null_versioned_model_v2_id" ,
102140 "local.source_custom_notnull_name_raw_my_source_id" ,
103141 "local.source_not_null_raw_my_source_id" ,
104142 ]
0 commit comments