From df56955bf0f0197af869da94ec33ea697e332d18 Mon Sep 17 00:00:00 2001 From: grossmj Date: Tue, 17 Dec 2024 15:01:01 +0700 Subject: [PATCH] Use license instead of licence --- gns3server/compute/iou/iou_vm.py | 10 +++++----- tests/compute/iou/test_iou_vm.py | 26 +++++++++++++------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/gns3server/compute/iou/iou_vm.py b/gns3server/compute/iou/iou_vm.py index 970621d0..d82776ba 100644 --- a/gns3server/compute/iou/iou_vm.py +++ b/gns3server/compute/iou/iou_vm.py @@ -390,9 +390,9 @@ class IOUVM(BaseNode): raise IOUError("The following shared library dependencies cannot be found for IOU image {}: {}".format(self._path, ", ".join(missing_libs))) - def _is_iou_licence_check_enabled(self): + def _is_iou_license_check_enabled(self): """ - Returns if IOU licence check is enabled. + Returns if IOU license check is enabled. :return: boolean """ @@ -413,7 +413,7 @@ class IOUVM(BaseNode): return True - async def _check_iou_licence(self): + async def _check_iou_license(self): """ Checks for a valid IOU key in the iourc file (paranoid mode). """ @@ -521,13 +521,13 @@ class IOUVM(BaseNode): raise IOUError("Could not rename nvram files: {}".format(e)) iourc_path = None - if self._is_iou_licence_check_enabled(): + if self._is_iou_license_check_enabled(): iourc_path = self.iourc_path if not iourc_path: raise IOUError("Could not find an iourc file (IOU license), please configure an IOU license") if not os.path.isfile(iourc_path): raise IOUError("The iourc path '{}' is not a regular file".format(iourc_path)) - await self._check_iou_licence() + await self._check_iou_license() await self._start_ubridge() self._create_netmap_config() diff --git a/tests/compute/iou/test_iou_vm.py b/tests/compute/iou/test_iou_vm.py index 39b39ca0..d3026295 100644 --- a/tests/compute/iou/test_iou_vm.py +++ b/tests/compute/iou/test_iou_vm.py @@ -96,7 +96,7 @@ async def test_start(vm): mock_process = MagicMock() vm._check_requirements = AsyncioMagicMock(return_value=True) - vm._check_iou_licence = AsyncioMagicMock(return_value=True) + vm._check_iou_license = AsyncioMagicMock(return_value=True) vm._start_ubridge = AsyncioMagicMock(return_value=True) vm._ubridge_send = AsyncioMagicMock() @@ -108,7 +108,7 @@ async def test_start(vm): assert vm.command_line == ' '.join(mock_exec.call_args[0]) assert vm._check_requirements.called - assert vm._check_iou_licence.called + assert vm._check_iou_license.called assert vm._start_ubridge.called vm._ubridge_send.assert_any_call("iol_bridge delete IOL-BRIDGE-513") vm._ubridge_send.assert_any_call("iol_bridge create IOL-BRIDGE-513 513") @@ -123,8 +123,8 @@ async def test_start_with_iourc(vm, tmpdir): mock_process = MagicMock() vm._check_requirements = AsyncioMagicMock(return_value=True) - vm._is_iou_licence_check_enabled = AsyncioMagicMock(return_value=True) - vm._check_iou_licence = AsyncioMagicMock(return_value=True) + vm._is_iou_license_check_enabled = AsyncioMagicMock(return_value=True) + vm._check_iou_license = AsyncioMagicMock(return_value=True) vm._start_ioucon = AsyncioMagicMock(return_value=True) vm._start_ubridge = AsyncioMagicMock(return_value=True) vm._ubridge_send = AsyncioMagicMock() @@ -159,7 +159,7 @@ async def test_stop(vm): process = MagicMock() vm._check_requirements = AsyncioMagicMock(return_value=True) - vm._check_iou_licence = AsyncioMagicMock(return_value=True) + vm._check_iou_license = AsyncioMagicMock(return_value=True) vm._start_ioucon = AsyncioMagicMock(return_value=True) vm._start_ubridge = AsyncioMagicMock(return_value=True) vm._ubridge_send = AsyncioMagicMock() @@ -184,7 +184,7 @@ async def test_reload(vm, fake_iou_bin): process = MagicMock() vm._check_requirements = AsyncioMagicMock(return_value=True) - vm._check_iou_licence = AsyncioMagicMock(return_value=True) + vm._check_iou_license = AsyncioMagicMock(return_value=True) vm._start_ioucon = AsyncioMagicMock(return_value=True) vm._start_ubridge = AsyncioMagicMock(return_value=True) vm._ubridge_send = AsyncioMagicMock() @@ -377,42 +377,42 @@ def test_get_legacy_vm_workdir(): async def test_invalid_iou_file(vm, iourc_file): hostname = socket.gethostname() - await vm._check_iou_licence() + await vm._check_iou_license() # Missing ; with pytest.raises(IOUError): with open(iourc_file, "w+") as f: f.write("[license]\n{} = aaaaaaaaaaaaaaaa".format(hostname)) - await vm._check_iou_licence() + await vm._check_iou_license() # Key too short with pytest.raises(IOUError): with open(iourc_file, "w+") as f: f.write("[license]\n{} = aaaaaaaaaaaaaa;".format(hostname)) - await vm._check_iou_licence() + await vm._check_iou_license() # Invalid hostname with pytest.raises(IOUError): with open(iourc_file, "w+") as f: f.write("[license]\nbla = aaaaaaaaaaaaaa;") - await vm._check_iou_licence() + await vm._check_iou_license() # Missing licence section with pytest.raises(IOUError): with open(iourc_file, "w+") as f: f.write("[licensetest]\n{} = aaaaaaaaaaaaaaaa;") - await vm._check_iou_licence() + await vm._check_iou_license() # Broken config file with pytest.raises(IOUError): with open(iourc_file, "w+") as f: f.write("[") - await vm._check_iou_licence() + await vm._check_iou_license() # Missing file with pytest.raises(IOUError): os.remove(iourc_file) - await vm._check_iou_licence() + await vm._check_iou_license() def test_iourc_content(vm):