Files
govoplan/tests/test_worker_runtime_drill.py
T
zemion d3713bf2ee
Dependency Audit / dependency-audit (push) Failing after 9s
Deployment Installer / deployment-installer (push) Successful in 5s
Security Audit / security-audit (push) Failing after 8s
Automate worker runtime delivery drill
2026-08-03 00:20:57 +02:00

43 lines
1.4 KiB
Python

from __future__ import annotations
import importlib.util
from pathlib import Path
import sys
import unittest
SCRIPT = Path(__file__).resolve().parents[1] / "tools" / "checks" / "worker-runtime-drill.py"
SPEC = importlib.util.spec_from_file_location("worker_runtime_drill", SCRIPT)
assert SPEC is not None and SPEC.loader is not None
MODULE = importlib.util.module_from_spec(SPEC)
sys.modules[SPEC.name] = MODULE
SPEC.loader.exec_module(MODULE)
class WorkerRuntimeDrillTests(unittest.TestCase):
def test_redacts_redis_credentials_and_query(self) -> None:
self.assertEqual(
"rediss://redis.example.test:6380/9",
MODULE._redacted_redis_url(
"rediss://worker:secret@redis.example.test:6380/9?ssl=true"
),
)
def test_worker_command_uses_solo_default_queue_for_deterministic_drill(self) -> None:
command = MODULE._worker_command("/usr/bin/python", "worker-a@%h")
self.assertEqual("/usr/bin/python", command[0])
self.assertIn("solo", command)
self.assertIn("default", command)
self.assertIn("worker-a@%h", command)
def test_rejects_implicit_or_non_redis_broker(self) -> None:
args = MODULE.build_parser().parse_args(["--redis-url", "memory://"])
with self.assertRaisesRegex(ValueError, "explicit redis"):
MODULE.run_drill(args)
if __name__ == "__main__":
unittest.main()