From 55635ab5511180da94618ca557161fb0622fab25 Mon Sep 17 00:00:00 2001 From: Christian Manivong Date: Tue, 1 Sep 2026 05:55:30 +0200 Subject: [PATCH] test: cover the uname -r call get_facts gained MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit d337398 added a fifth _send() to get_facts without extending the three get_facts tests' side_effect lists, so each of them ran out of canned responses and died on StopIteration. Red since 2026-08-23 — nothing gates this repo, so it simply stayed red. Adds the kernel release to each list and asserts running_kernel, which had no coverage at all before. --- tests/test_linux.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/test_linux.py b/tests/test_linux.py index 6972396..c3f58f6 100644 --- a/tests/test_linux.py +++ b/tests/test_linux.py @@ -639,13 +639,16 @@ def test_get_facts_baremetal_vendor_model_serial(driver): platform = {"vendor": "Dell Inc.", "model": "PowerEdge R720", "serial": "ABC123", "is_vm": False} with patch.object(driver, "_collect_platform_info", return_value=platform), \ patch.object(driver, "_parse_uptime", return_value=86400), \ - patch.object(driver, "_send", side_effect=["myhost", "myhost.example.com", "Debian GNU/Linux 12", "eth0\neth1"]): + patch.object(driver, "_send", side_effect=["myhost", "myhost.example.com", "Debian GNU/Linux 12", "eth0\neth1", + "6.1.0-18-amd64"]): facts = driver.get_facts() assert facts["vendor"] == "Dell Inc." assert facts["model"] == "PowerEdge R720" assert facts["serial_number"] == "ABC123" assert facts["hostname"] == "myhost" assert facts["uptime"] == 86400 + # Booted kernel, not the newest installed one — kernel CVE relevance needs it. + assert facts["running_kernel"] == "6.1.0-18-amd64" def test_get_facts_vm_kvm(driver): @@ -655,7 +658,8 @@ def test_get_facts_vm_kvm(driver): } with patch.object(driver, "_collect_platform_info", return_value=platform), \ patch.object(driver, "_parse_uptime", return_value=3600), \ - patch.object(driver, "_send", side_effect=["vmhost", "vmhost.local", "Ubuntu 22.04 LTS", "eth0"]): + patch.object(driver, "_send", side_effect=["vmhost", "vmhost.local", "Ubuntu 22.04 LTS", "eth0", + "5.15.0-91-generic"]): facts = driver.get_facts() assert facts["vendor"] == "KVM" assert facts["model"] == "Virtual Machine" @@ -666,7 +670,7 @@ def test_get_facts_fallback_vendor_when_dmi_empty(driver): platform = {"vendor": "", "model": "", "serial": "", "is_vm": False} with patch.object(driver, "_collect_platform_info", return_value=platform), \ patch.object(driver, "_parse_uptime", return_value=0), \ - patch.object(driver, "_send", side_effect=["host", "host.local", "Alpine Linux 3.19", "eth0"]): + patch.object(driver, "_send", side_effect=["host", "host.local", "Alpine Linux 3.19", "eth0", "6.6.7-0-lts"]): facts = driver.get_facts() assert facts["vendor"] == "Linux" # fallback to VENDOR class attribute