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

+33
View File
@@ -113,5 +113,38 @@ class TestCliIntegration(unittest.TestCase):
finally:
sys.stdout = old_stdout
def test_cli_sort_by_ip(self):
stdout_capture = StringIO()
old_stdout = sys.stdout
try:
sys.stdout = stdout_capture
code = main(["--check", "-q", "--sort", "ip"])
self.assertEqual(code, 0)
out = stdout_capture.getvalue()
# node0 (192.168.0.101) must appear before k3s-master-0 (192.168.5.70)
pos_node0 = out.find("node0")
pos_k3s = out.find("k3s-master-0")
self.assertNotEqual(pos_node0, -1)
self.assertNotEqual(pos_k3s, -1)
self.assertLess(pos_node0, pos_k3s)
finally:
sys.stdout = old_stdout
def test_cli_sync_destination_overrides(self):
with TemporaryDirectory() as tmpdir:
ansible_file = Path(tmpdir) / "custom_ansible.yaml"
lc_file = Path(tmpdir) / "custom_lc.yaml"
code = main([
"--sync", "-q",
"--ansible-dest", str(ansible_file),
"--lc-dest", str(lc_file)
])
self.assertEqual(code, 0)
self.assertTrue(ansible_file.exists())
self.assertTrue(lc_file.exists())
self.assertIn("all:", ansible_file.read_text(encoding="utf-8"))
self.assertIn("hosts:", lc_file.read_text(encoding="utf-8"))
if __name__ == "__main__":
unittest.main()
+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()
+7 -7
View File
@@ -33,13 +33,13 @@ class TestPackaging(unittest.TestCase):
def test_get_version(self):
version = get_version(self.source_root)
self.assertEqual(version, "1.1.0")
self.assertEqual(version, "1.1.1")
def test_build_tarball(self):
builder = PackageBuilder(
source_root=self.source_root,
output_dir=self.output_dir,
version="1.1.0",
version="1.1.1",
)
tar_path = builder.build_tarball()
self.assertTrue(tar_path.exists())
@@ -48,16 +48,16 @@ class TestPackaging(unittest.TestCase):
# Verify tar contents
with tarfile.open(str(tar_path), "r:gz") as tar:
names = tar.getnames()
self.assertIn("inventory-collector-1.1.0/bin/inventory-collector", names)
self.assertIn("inventory-collector-1.1.0/inventory_collector/__init__.py", names)
self.assertIn("inventory-collector-1.1.0/install.sh", names)
self.assertIn("inventory-collector-1.1.0/packaging/install.sh", names)
self.assertIn("inventory-collector-1.1.1/bin/inventory-collector", names)
self.assertIn("inventory-collector-1.1.1/inventory_collector/__init__.py", names)
self.assertIn("inventory-collector-1.1.1/install.sh", names)
self.assertIn("inventory-collector-1.1.1/packaging/install.sh", names)
def test_build_deb(self):
builder = PackageBuilder(
source_root=self.source_root,
output_dir=self.output_dir,
version="1.1.0",
version="1.1.1",
)
deb_path = builder.build_deb()
self.assertTrue(deb_path.exists())