mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-28 13:57:43 +00:00
Work-in-progress commit on the collective code-scanning sidetree, so main can be merged in; the single quality-high gate runs on the integration branch before the pull request. Fixes the CodeQL notes py/import-and-import-from, py/unused-import, py/unused-global-variable, py/empty-except, py/mixed-tuple-returns and py/unused-local-variable across 194 files, and adds one lint per rule under tests/lint/repository/python/ so none of them can come back: test_import_and_import_from, test_unused_imports_hidden_from_ruff, test_unused_global_variables, test_empty_except, test_mixed_tuple_returns, test_unused_local_variables, plus test_modules_import. Accepted security finding: MEDUSA-MP-SCAN-2056 (low) on utils/i18n/client.py:21, an import line matched by a keyword heuristic; operator-confirmed false positive. 🎯 Fix: 85 % 💥 Break: 8 % 💸 Cost: – ⏱️ Time: – 🛡️ Security: 100 % 🏆 Score: 78 🚦 Gate: ⛔ fix 85 % < 90, break 8 % > 5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
import unittest
|
|
import unittest.mock
|
|
from types import SimpleNamespace
|
|
|
|
from cli.administration.deploy.swarm import command
|
|
|
|
|
|
class TestSwarmMain(unittest.TestCase):
|
|
def test_custom_roles_are_pulled_before_the_closure_reads_roles(self):
|
|
calls: list[str] = []
|
|
args = SimpleNamespace(id=["web-app-cst-demo"], inventory="inv/devices.yml")
|
|
|
|
def closure(ids, _inventory):
|
|
calls.append("closure")
|
|
return ids
|
|
|
|
with (
|
|
unittest.mock.patch.object(
|
|
command, "parse_args", return_value=(args, [], {})
|
|
),
|
|
unittest.mock.patch.object(
|
|
command,
|
|
"pull_custom_roles",
|
|
side_effect=lambda _args: calls.append("pull"),
|
|
),
|
|
unittest.mock.patch.object(
|
|
command, "swarm_deploy_targets", side_effect=closure
|
|
),
|
|
unittest.mock.patch.object(command, "run_from_args", return_value=0) as run,
|
|
):
|
|
self.assertEqual(0, command.main([]))
|
|
|
|
self.assertEqual(["pull", "closure"], calls)
|
|
run.assert_called_once_with(args, [], {})
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|