Commit cc40cea
authored
test: make constraints tests server-observable (add assertions, drop generated-SQL checks) (#1523)
Make the constraints functional tests assert **server-observable state**
rather than generated-SQL text or run-succeeded.
## Adds server-observable assertions
- **V1 contract-enforced table create** asserts PRIMARY KEY + FOREIGN
KEY + NOT NULL land in information_schema
(`TestV1ContractConstraintsApplied`). The V1 path was previously only
generated-SQL-tested.
- **type: custom** model constraint asserts delta.constraints.* via SHOW
TBLPROPERTIES (`TestCustomConstraint`).
- **Expression-form foreign key** asserts the referential constraint is
actually created (`TestIncrementalForeignKeyExpressionConstraint` was
previously assertion-free).
- **Incremental NOT NULL / CHECK removal** assert the after-state
(column nullable again / delta.constraints.* gone), not just that the
rerun succeeds.
- Enabled the previously-uncollected `TestInvalidColumnConstraints` (the
test method had a leading underscore, so pytest never ran it).
## Removes brittle generated-SQL checks
The `*DdlEnforcement` and quoted-column tests string-matched the
generated CREATE TABLE / ALTER SQL (reading target/run/*.sql), which is
brittle and outside the spirit of integration tests. Constraint SQL
generation is already unit-pinned in
tests/unit/macros/relations/test_constraint_macros.py, and the server
effect is now covered above. Removed
`TestTableConstraintsDdlEnforcement` /
`TestIncrementalConstraintsDdlEnforcement` /
`TestConstraintQuotedColumn` (V1 + V2), `BaseV2ConstraintSetup`, and the
`expected_sql` / `expected_sql_v2` fixtures. Kept the ColumnsEqual
(contract column matching) and rollback (server-observable enforcement)
tests.
No product code changes; tests only.
## Test plan
All new/strengthened assertions verified live on
databricks_uc_sql_endpoint; pre-commit (ruff / ruff-format / mypy)
clean.1 parent 860af64 commit cc40cea
6 files changed
Lines changed: 179 additions & 206 deletions
File tree
- tests/functional/adapter
- constraints
- incremental
- persist_constraints
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 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 | 3 | | |
30 | 4 | | |
31 | 5 | | |
| |||
318 | 292 | | |
319 | 293 | | |
320 | 294 | | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
Lines changed: 42 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
6 | 10 | | |
7 | 11 | | |
8 | 12 | | |
| |||
128 | 132 | | |
129 | 133 | | |
130 | 134 | | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
Lines changed: 34 additions & 66 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | 5 | | |
7 | | - | |
8 | 6 | | |
9 | 7 | | |
10 | | - | |
11 | 8 | | |
12 | 9 | | |
13 | 10 | | |
| |||
86 | 83 | | |
87 | 84 | | |
88 | 85 | | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | 86 | | |
125 | 87 | | |
126 | 88 | | |
| |||
200 | 162 | | |
201 | 163 | | |
202 | 164 | | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
203 | 178 | | |
204 | 179 | | |
205 | | - | |
| 180 | + | |
206 | 181 | | |
207 | 182 | | |
208 | 183 | | |
209 | 184 | | |
210 | 185 | | |
211 | 186 | | |
212 | 187 | | |
213 | | - | |
214 | | - | |
215 | | - | |
| 188 | + | |
| 189 | + | |
216 | 190 | | |
217 | 191 | | |
218 | | - | |
219 | | - | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
220 | 203 | | |
221 | 204 | | |
222 | | - | |
| 205 | + | |
| 206 | + | |
223 | 207 | | |
224 | 208 | | |
225 | 209 | | |
226 | 210 | | |
227 | 211 | | |
228 | 212 | | |
229 | 213 | | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
234 | 217 | | |
235 | 218 | | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
| 219 | + | |
| 220 | + | |
0 commit comments