|
18 | 18 |
|
19 | 19 | class TestRuleRegistry: |
20 | 20 | def test_all_rules_loaded(self) -> None: |
21 | | - assert len(ALL_RULES) == 33 |
| 21 | + assert len(ALL_RULES) == 34 |
22 | 22 |
|
23 | 23 | def test_10_errors(self) -> None: |
24 | 24 | # 8 E-series + 2 T-series (T002 xp-cmdshell, T004 deprecated-outer-join). |
25 | 25 | errors = [r for r in ALL_RULES if r.severity == "error"] |
26 | 26 | assert len(errors) == 10 |
27 | 27 |
|
28 | | - def test_23_warnings(self) -> None: |
29 | | - # 17 W-series + 3 S-series + 3 T-series (T001 with-nolock, |
| 28 | + def test_24_warnings(self) -> None: |
| 29 | + # 18 W-series + 3 S-series + 3 T-series (T001 with-nolock, |
30 | 30 | # T003 cursor-declaration, T005 create-index-without-online). |
31 | 31 | warnings = [r for r in ALL_RULES if r.severity == "warning"] |
32 | | - assert len(warnings) == 23 |
| 32 | + assert len(warnings) == 24 |
33 | 33 |
|
34 | 34 | def test_unique_ids(self) -> None: |
35 | 35 | ids = [r.id for r in ALL_RULES] |
@@ -166,6 +166,19 @@ def test_w012_passes_on_digit_prefixed_column_name(self) -> None: |
166 | 166 | statement = "SELECT 1st_quarter, COUNT(*) FROM sales GROUP BY 1st_quarter;" |
167 | 167 | assert rule.check_statement(statement, 1, "test.sql") is None |
168 | 168 |
|
| 169 | + def test_w013_window_missing_partition(self) -> None: |
| 170 | + findings = check([str(FIXTURES / "warnings.sql")]) |
| 171 | + w013 = [f for f in findings.findings if f.rule_id == "W013"] |
| 172 | + assert len(w013) >= 1 |
| 173 | + |
| 174 | + def test_w013_passes_on_valid_over_clause(self) -> None: |
| 175 | + from sql_guard.rules.warnings import WindowMissingPartition |
| 176 | + |
| 177 | + rule = WindowMissingPartition() |
| 178 | + statement = "SELECT ROW_NUMBER() OVER (PARTITION BY department_id ORDER BY id) AS rn FROM users;" |
| 179 | + |
| 180 | + assert rule.check_statement(statement, 1, "test.sql") is None |
| 181 | + |
169 | 182 | def test_w016_not_in_with_subquery(self) -> None: |
170 | 183 | findings = check([str(FIXTURES / "warnings.sql")]) |
171 | 184 | w016 = [f for f in findings.findings if f.rule_id == "W016"] |
|
0 commit comments