From b5d5dffeaf74ebcac6830288d3bafc6bc6ebc638 Mon Sep 17 00:00:00 2001 From: sjat Date: Thu, 18 Jun 2026 12:11:56 +0200 Subject: [PATCH] feat(integration-vm): vm naming, RAM guard, lease IP parsing --- tests/test_integration_vm.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/test_integration_vm.py b/tests/test_integration_vm.py index 4eab622..2c8e107 100644 --- a/tests/test_integration_vm.py +++ b/tests/test_integration_vm.py @@ -9,3 +9,24 @@ _spec.loader.exec_module(ivm) def test_valid_tiers(): assert ivm.VALID_TIERS == ("internal", "le-staging", "le-prod-wildcard") + + +def test_vm_name_prefix_and_suffix(): + assert ivm.vm_name("askari", "ab12cd34") == "boma-it-askari-ab12cd34" + +def test_vm_name_generates_suffix(): + n = ivm.vm_name("askari") + assert n.startswith("boma-it-askari-") and len(n.split("-")[-1]) == 8 + +def test_free_mib_parses_memavailable(): + sample = "MemTotal: 16331156 kB\nMemAvailable: 8388608 kB\n" + assert ivm.free_mib(sample) == 8192 + +def test_parse_lease_ip_extracts_ipv4(): + out = (" Name MAC address Protocol Address\n" + "-------------------------------------------------------------------\n" + " vnet0 52:54:00:aa:bb:cc ipv4 192.168.150.42/24\n") + assert ivm.parse_lease_ip(out) == "192.168.150.42" + +def test_parse_lease_ip_none_when_absent(): + assert ivm.parse_lease_ip("no leases\n") is None