From 1f29d9d57d39f9a7ad5d38500a333f95546aa3fb Mon Sep 17 00:00:00 2001 From: Christian Manivong Date: Fri, 24 Jul 2026 10:26:01 +0200 Subject: [PATCH] fix(tests): correct ADDRESSES_RESPONSE fixture shape in TestGetInterfacesIp Verified against a live OPNsense 24.7 instance: GET /api/interfaces/overview/export returns a bare list of interface dicts keyed by "device" with CIDR "addr4"/"addr6" strings, matching what get_interfaces_ip() already parses. The fixture's "items"/"interface"/ "address"/"prefix" shape never matched, so all four TestGetInterfacesIp tests failed regardless of driver correctness. --- tests/unit/test_driver.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/unit/test_driver.py b/tests/unit/test_driver.py index 5d8a6b0..0a95a56 100644 --- a/tests/unit/test_driver.py +++ b/tests/unit/test_driver.py @@ -61,13 +61,16 @@ INTERFACES_RESPONSE = { ] } -ADDRESSES_RESPONSE = { - "items": [ - {"interface": "em0", "address": "192.0.2.10", "prefix": 24}, - {"interface": "em0", "address": "2001:db8::1", "prefix": 64}, - {"interface": "em1", "address": "203.0.113.5", "prefix": 30}, - ] -} +# Real shape confirmed against a live OPNsense 24.7 instance's +# GET /api/interfaces/overview/export (see issue #14): a bare top-level list +# of interface dicts, addressed via "device" and CIDR "addr4"/"addr6" +# strings — not the "items"/"interface"/"address"/"prefix" shape this +# fixture previously assumed, which never matched get_interfaces_ip()'s +# actual parsing and made all four TestGetInterfacesIp tests fail. +ADDRESSES_RESPONSE = [ + {"device": "em0", "addr4": "192.0.2.10/24", "addr6": "2001:db8::1/64"}, + {"device": "em1", "addr4": "203.0.113.5/30", "addr6": ""}, +] ARP_RESPONSE = { "arp": [