mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-29 06:17:25 +00:00
CodeQL 978 and 979 (py/missing-equals): _Manager in the Funkwhale design-preferences test and _Tripwire in the resource lookup test add an attribute to a dict subclass without comparing it; both now define __eq__ over the dict content plus that attribute. CodeQL 1138 (py/import-and-import-from): test_requires_python imports unittest and unittest.mock once each instead of both import forms. 🎯 Fix: 92 % 💥 Break: 1 % 💸 Cost: 100 % ⏱️ Time: 100 % 🛡️ Security: ~100 % 🏆 Score: 91 🚦 Gate: ✅ 90/5, cost and time <= 100, security 100 % Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
30 lines
920 B
Python
30 lines
920 B
Python
from __future__ import annotations
|
|
|
|
import tempfile
|
|
import unittest
|
|
import unittest.mock
|
|
from pathlib import Path
|
|
|
|
from ansible.errors import AnsibleError
|
|
|
|
from plugins.lookup import requires_python as plugin
|
|
|
|
|
|
class TestRequiresPythonLookup(unittest.TestCase):
|
|
def test_the_lookup_returns_the_pyproject_spec(self) -> None:
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
Path(tmp, "pyproject.toml").write_text(
|
|
'[project]\nname = "demo"\nrequires-python = ">=3.12,<3.14"\n',
|
|
encoding="utf-8",
|
|
)
|
|
with unittest.mock.patch.object(plugin, "PROJECT_ROOT", Path(tmp)):
|
|
self.assertEqual(plugin.LookupModule().run([]), [">=3.12,<3.14"])
|
|
|
|
def test_the_lookup_takes_no_terms(self) -> None:
|
|
with self.assertRaises(AnsibleError):
|
|
plugin.LookupModule().run(["range"])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|