Files
kevinveenbirkenbachandClaude Opus 5.5 037f298d3c fix(web-app-openwebui): read the helper tasks through the cached helpers in the migration test
The test added in #2150 walked the role with Path.rglob and loaded each file with yaml.safe_load(path.read_text()). Three lints of test-lint forbid exactly that (test_no_raw_project_walk, test_no_direct_calls, test_no_uncached_file_reads), so main's quality gate 453 failed on origin/main 3db30e287f. The test now takes the files from iter_project_files and loads them with load_yaml_any. A negative control with ENABLE_DB_MIGRATIONS=true in the MCP grant helper still fails it. Main gate 455 on this tree is green.

🎯 Fix: 93 %
💥 Break: 1 %
💸 Tokens: –
⏱️ Velocity: –
🛡️ Security: 100 %
🏆 Score: 92
🚦 Gate: ✅ 90/5, tokens and velocity <= 100, security 100 %

Created-with: https://s.veen.world/skills
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 14:17:34 +00:00

49 lines
1.5 KiB
Python

from __future__ import annotations
import json
import unittest
from pathlib import Path
from utils.cache.files import iter_project_files
from utils.cache.yaml import load_yaml_any
from . import PROJECT_ROOT
TASKS_DIR = PROJECT_ROOT / "roles/web-app-openwebui/tasks"
HELPER_FILES = {"admin.yml", "agent_models.yml", "mcp_grants.yml"}
def python_execs() -> dict[str, str]:
"""
Returns:
The serialised command of each such task, keyed by
``<file>: <task name>``.
"""
found = {}
paths = (Path(p) for p in iter_project_files(extensions=(".yml",)))
for path in sorted(p for p in paths if p.is_relative_to(TASKS_DIR)):
for task in load_yaml_any(str(path)) or []:
for module in ("ansible.builtin.command", "ansible.builtin.shell"):
command = json.dumps(task.get(module, ""))
if "exec" in command and "python3" in command:
found[f"{path.name}: {task['name']}"] = command
return found
class TestHelpersSkipMigrations(unittest.TestCase):
def test_every_helper_file_is_scanned(self):
scanned = {key.split(":", 1)[0] for key in python_execs()}
self.assertEqual(HELPER_FILES - scanned, set())
def test_every_python_exec_disables_migrations(self):
missing = [
key
for key, command in python_execs().items()
if "ENABLE_DB_MIGRATIONS=false" not in command
]
self.assertEqual(missing, [])
if __name__ == "__main__":
unittest.main()