feat: release v1.1.1 - host sorting by name/IP, sync destination overrides, and ~ expansion
Build and Publish Release / Build Packages and Publish (push) Successful in 25s

This commit is contained in:
soda64 committed 2026-10-03 22:05:00 +02:00
1 parent 598e5d7397
commit 62710d8bb7
19 files changed
+190 -34

No files matched your search

+29
View File
@@ -71,5 +71,34 @@ class TestDeduplicationEngine(unittest.TestCase):
merged = inv.get_host("node0")
self.assertEqual(merged.ansible_user, "root")
def test_inventory_sort_by_name(self):
from inventory_collector.models import InventoryData
inv = InventoryData()
inv.add_host(HostRecord(name="zebra", ansible_host="10.0.0.1"))
inv.add_host(HostRecord(name="alpha", ansible_host="10.0.0.2"))
inv.add_host(HostRecord(name="beta", ansible_host="10.0.0.3"))
sorted_inv = inv.sort(sort_by="name")
self.assertEqual(list(sorted_inv.hosts.keys()), ["alpha", "beta", "zebra"])
rev_inv = inv.sort(sort_by="name", reverse=True)
self.assertEqual(list(rev_inv.hosts.keys()), ["zebra", "beta", "alpha"])
def test_inventory_sort_by_ip(self):
from inventory_collector.models import InventoryData
inv = InventoryData()
inv.add_host(HostRecord(name="host-101", ansible_host="192.168.0.101"))
inv.add_host(HostRecord(name="host-2", ansible_host="192.168.0.2"))
inv.add_host(HostRecord(name="host-20", ansible_host="192.168.0.20"))
inv.add_host(HostRecord(name="host-no-ip", ansible_host=""))
# In string sorting, "192.168.0.101" < "192.168.0.2".
# But numerical octet sorting correctly places .2 before .20 before .101!
sorted_inv = inv.sort(sort_by="ip")
self.assertEqual(list(sorted_inv.hosts.keys()), ["host-2", "host-20", "host-101", "host-no-ip"])
rev_inv = inv.sort(sort_by="ip", reverse=True)
self.assertEqual(list(rev_inv.hosts.keys()), ["host-no-ip", "host-101", "host-20", "host-2"])
if __name__ == "__main__":
unittest.main()