mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-08 11:46:35 +00:00
Merge branch 'feature/updater' into feature/store-i18n
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> # Conflicts: # plugins/lookup/deployment.py
This commit is contained in:
commit
2c04cce617
10 files changed
+245
-32
No files matched your search
@@ -29,6 +29,7 @@ class TestDeploymentLookup(unittest.TestCase):
|
||||
"inventory",
|
||||
"deployed",
|
||||
"runtime",
|
||||
"ephemeral",
|
||||
"all",
|
||||
},
|
||||
)
|
||||
@@ -225,6 +226,7 @@ class TestDeploymentLookup(unittest.TestCase):
|
||||
)
|
||||
self.assertEqual(result[0]["deployed"], ["only-this"])
|
||||
self.assertEqual(result[0]["runtime"], runtime)
|
||||
self.assertTrue(result[0]["ephemeral"])
|
||||
|
||||
@patch("plugins.lookup.deployment.list_invokable_app_ids")
|
||||
def test_deployed_uses_groups_in_persistent_runtime(self, mock_list):
|
||||
@@ -243,6 +245,7 @@ class TestDeploymentLookup(unittest.TestCase):
|
||||
result[0]["deployed"],
|
||||
["partial", "still-running", "also-running"],
|
||||
)
|
||||
self.assertFalse(result[0]["ephemeral"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
"""Unit tests for ``plugins/lookup/mcp_servers.py``.
|
||||
|
||||
Only the pure builder and the credential resolver are exercised; the lookup
|
||||
wrapper forwards ``roles_with_service``, ``applications`` and ``users`` into
|
||||
them.
|
||||
The pure builder, the credential resolver and the deploy closure are exercised;
|
||||
the lookup wrapper forwards ``roles_with_service``, ``applications`` and ``users``
|
||||
into them.
|
||||
"""
|
||||
|
||||
import importlib
|
||||
import unittest
|
||||
from typing import ClassVar
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from ansible.errors import AnsibleError
|
||||
|
||||
@@ -89,6 +90,34 @@ class TestSelectDeployed(unittest.TestCase):
|
||||
self.assertEqual([], plugin_module.select_deployed(None, {"web-app-hermes"}))
|
||||
|
||||
|
||||
class TestDeployClosure(unittest.TestCase):
|
||||
def closure(self, deployment):
|
||||
def get(name, **kwargs):
|
||||
plugin = MagicMock()
|
||||
if name == "deployment":
|
||||
plugin.run.return_value = [deployment]
|
||||
else:
|
||||
plugin.run.side_effect = lambda terms, variables=None: [
|
||||
{*terms[0], "svc-db-postgres"}
|
||||
]
|
||||
return plugin
|
||||
|
||||
with patch.object(plugin_module.lookup_loader, "get", side_effect=get):
|
||||
return plugin_module.LookupModule()._deploy_closure(None, {})
|
||||
|
||||
def test_a_partial_run_on_a_persistent_host_narrows_nothing(self):
|
||||
self.assertEqual(
|
||||
set(),
|
||||
self.closure({"ephemeral": False, "whitelist": ["web-opt-rdr-domains"]}),
|
||||
)
|
||||
|
||||
def test_an_ephemeral_run_narrows_to_the_whitelist_closure(self):
|
||||
self.assertEqual(
|
||||
{"web-app-hermes", "svc-db-postgres"},
|
||||
self.closure({"ephemeral": True, "whitelist": ["web-app-hermes"]}),
|
||||
)
|
||||
|
||||
|
||||
class TestBuildMcpDiscovery(unittest.TestCase):
|
||||
def test_no_servers_yields_nothing(self):
|
||||
for servers in (None, []):
|
||||
|
||||
Reference in new issue
Block a user