mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-11 21:26:44 +00:00
Move:
- cli/build/inventory/full -> cli/administration/inventory/devices
- cli/create/inventory -> cli/administration/inventory/provision
- cli/create/credentials -> cli/administration/inventory/credentials
- cli/encrypt/inventory -> cli/administration/inventory/encrypt
Delete:
- cli/create/role + templates/roles/ (stale scaffolder)
- roles/web-app-baserow/templates/javascript.js.j2 + dead sso_warning snippet
- js_application_name across akaunting/baserow/opencloud/opentalk/taiga,
javascript service disabled for baserow + taiga
Wire-through:
- argv lists in cli/deploy/{container,development}/* + 2 shell scripts
now invoke 'infinito administration inventory provision'
- subprocess module names + docs (contributing/* + administration/deploy.md)
- discovery resolver test + folder-item-limit whitelist updated
- ruff fixes in devices/command.py (RET504 inline + Path.open over open)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
69 lines
2.2 KiB
Python
69 lines
2.2 KiB
Python
from __future__ import annotations
|
|
|
|
import sys
|
|
import unittest
|
|
|
|
from . import PROJECT_ROOT
|
|
|
|
# Ensure repo root is importable (so `import cli...` works in all runners)
|
|
if str(PROJECT_ROOT) not in sys.path:
|
|
sys.path.insert(0, str(PROJECT_ROOT))
|
|
|
|
from cli.administration.inventory.devices import command as devices
|
|
|
|
|
|
class TestFullInventoryCommand(unittest.TestCase):
|
|
def test_build_group_inventory(self):
|
|
apps = ["app1", "app2"]
|
|
host = "myhost"
|
|
|
|
inventory = devices.build_group_inventory(apps, host)
|
|
|
|
self.assertIn("all", inventory)
|
|
self.assertIn("app1", inventory)
|
|
self.assertIn("app2", inventory)
|
|
self.assertEqual(inventory["app1"], {"hosts": [host]})
|
|
self.assertEqual(inventory["all"]["hosts"], [host])
|
|
self.assertIn("app1", inventory["all"]["children"])
|
|
|
|
def test_build_hostvar_inventory(self):
|
|
apps = ["foo", "bar"]
|
|
host = "testhost"
|
|
|
|
inventory = devices.build_hostvar_inventory(apps, host)
|
|
|
|
self.assertIn("all", inventory)
|
|
self.assertIn("_meta", inventory)
|
|
self.assertIn("hostvars", inventory["_meta"])
|
|
self.assertEqual(
|
|
inventory["_meta"]["hostvars"][host]["invokable_applications"], apps
|
|
)
|
|
self.assertEqual(inventory["all"]["hosts"], [host])
|
|
|
|
def test_ignore_filtering(self):
|
|
# Simulate argument parsing logic for ignore flattening
|
|
ignore_args = ["foo,bar", "baz"]
|
|
ignore_ids: set[str] = set()
|
|
for entry in ignore_args:
|
|
ignore_ids.update(i.strip() for i in entry.split(",") if i.strip())
|
|
self.assertEqual(ignore_ids, {"foo", "bar", "baz"})
|
|
|
|
# Filtering list
|
|
apps = ["foo", "bar", "baz", "other"]
|
|
filtered = [app for app in apps if app not in ignore_ids]
|
|
self.assertEqual(filtered, ["other"])
|
|
|
|
def test_ignore_filtering_empty(self):
|
|
ignore_args: list[str] = []
|
|
ignore_ids: set[str] = set()
|
|
for entry in ignore_args:
|
|
ignore_ids.update(i.strip() for i in entry.split(",") if i.strip())
|
|
|
|
apps = ["a", "b"]
|
|
filtered = [app for app in apps if app not in ignore_ids]
|
|
self.assertEqual(filtered, ["a", "b"])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|