test: fix self-scan UPDATE alternative and POSIX path joining
- UPDATE pattern alternative corrected (UPDATE ... children, not UPDATE SET) - allowlist comparison uses as_posix() so Windows separators cannot make the DAO itself appear as an offender
This commit is contained in:
@@ -492,7 +492,7 @@ def test_children_and_admin_sql_lives_only_in_dao_module() -> None:
|
|||||||
offenders: list[str] = []
|
offenders: list[str] = []
|
||||||
for root in scan_roots:
|
for root in scan_roots:
|
||||||
for py in sorted(root.rglob("*.py")):
|
for py in sorted(root.rglob("*.py")):
|
||||||
relative = str(py.relative_to(repo_root))
|
relative = py.relative_to(repo_root).as_posix()
|
||||||
if relative in allowed:
|
if relative in allowed:
|
||||||
continue
|
continue
|
||||||
if sql_pattern.search(py.read_text()):
|
if sql_pattern.search(py.read_text()):
|
||||||
@@ -543,7 +543,7 @@ def test_dao_test_file_uses_dao_not_raw_table_sql() -> None:
|
|||||||
if number not in excluded
|
if number not in excluded
|
||||||
)
|
)
|
||||||
sql_pattern = re.compile(
|
sql_pattern = re.compile(
|
||||||
r"(SELECT\s[^\"']*?FROM|INSERT\s+INTO|UPDATE\s+SET|"
|
r"(SELECT\s[^\"']*?FROM|INSERT\s+INTO|UPDATE|"
|
||||||
r"DELETE\s+FROM|FROM|JOIN)\s+['\"]*"
|
r"DELETE\s+FROM|FROM|JOIN)\s+['\"]*"
|
||||||
r"(children|admin_users)\b",
|
r"(children|admin_users)\b",
|
||||||
re.IGNORECASE,
|
re.IGNORECASE,
|
||||||
|
|||||||
Reference in New Issue
Block a user