From 94a3a791cd5f9ec24bbc4e34a55fc3a0ca74fed1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Wed, 21 Aug 2024 16:32:26 +0200 Subject: [PATCH] Refactor network tests and update MAC address handling for consistency --- server/src/tests/services/proxmox/fixtures.py | 2 +- server/src/tests/services/proxmox/test_client.py | 7 +++++++ server/src/tests/services/proxmox/test_service_fixed.py | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/server/src/tests/services/proxmox/fixtures.py b/server/src/tests/services/proxmox/fixtures.py index a743accbf..6f80d89cb 100644 --- a/server/src/tests/services/proxmox/fixtures.py +++ b/server/src/tests/services/proxmox/fixtures.py @@ -183,7 +183,7 @@ DEF_VMS_CONFIGURATION: list[prox_types.VMConfiguration] = [ digest='digest', networks=[ prox_types.NetworkConfiguration( - net='net', type='type', mac=f'{i:02x}:{i+1:02x}:{i+2:02x}:{i+3:02x}:{i+4:02x}:{i+5:02x}' + net='net', type='type', macaddr=f'{i:02x}:{i+1:02x}:{i+2:02x}:{i+3:02x}:{i+4:02x}:{i+5:02x}' ) ], tpmstate0='tpmstate0', diff --git a/server/src/tests/services/proxmox/test_client.py b/server/src/tests/services/proxmox/test_client.py index a176af726..15f15873b 100644 --- a/server/src/tests/services/proxmox/test_client.py +++ b/server/src/tests/services/proxmox/test_client.py @@ -346,3 +346,10 @@ class TestProxmoxClient(UDSTransactionTestCase): vmconfig = self.pclient.get_vm_config(self.test_vm.id) self.assertIsInstance(vmconfig, prox_types.VMConfiguration) self.assertEqual(vmconfig.name, self.test_vm.name) + + def test_set_vm_net_mac(self) -> None: + with self._create_test_vm() as vm: + mac = '00:11:22:33:44:55' + self.pclient.set_vm_net_mac(vm.id, mac) + vmconfig = self.pclient.get_vm_config(vm.id) + self.assertEqual(vmconfig.networks[0].macaddr, mac) \ No newline at end of file diff --git a/server/src/tests/services/proxmox/test_service_fixed.py b/server/src/tests/services/proxmox/test_service_fixed.py index e8e098fd9..1361dc485 100644 --- a/server/src/tests/services/proxmox/test_service_fixed.py +++ b/server/src/tests/services/proxmox/test_service_fixed.py @@ -121,7 +121,7 @@ class TestProxmoxFixedService(UDSTransactionTestCase): # Get first network mac self.assertEqual( - service.get_mac('1'), fixtures.VMS_CONFIGURATION[0].networks[0].mac.lower() + service.get_mac('1'), fixtures.VMS_CONFIGURATION[0].networks[0].macaddr.lower() ) # Get guest ip address