From 377af7ffd0a50a3b8150b5f9d0c39816504eee30 Mon Sep 17 00:00:00 2001 From: Johann Wagner Date: Fri, 17 Jan 2025 09:41:16 +0100 Subject: [PATCH] Fixed tests --- cosmo/clients/netbox.py | 6 +++--- cosmo/tests/test_case_vrf_staticroute.yaml | 2 +- cosmo/tests/test_netboxclient.py | 3 ++- cosmo/tests/utils.py | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cosmo/clients/netbox.py b/cosmo/clients/netbox.py index 6f1a1f3..54ae4ac 100644 --- a/cosmo/clients/netbox.py +++ b/cosmo/clients/netbox.py @@ -16,12 +16,12 @@ def __init__(self, url, token): version = self.query_version() base_version_match = re.search(r'[\d.]+', version) - base_version = Version(base_version_match.group(0)) + self.base_version = Version(base_version_match.group(0)) - if base_version > Version("4.2.0"): + if self.base_version > Version("4.2.0"): log.info("Using version 4.2.x strategy...") self.child_client = NetboxV4Strategy(url, token, multiple_mac_addresses=True) - elif base_version > Version("4.0.0"): + elif self.base_version > Version("4.0.0"): log.info("Using version 4.0.x strategy...") self.child_client = NetboxV4Strategy(url, token, multiple_mac_addresses=False) else: diff --git a/cosmo/tests/test_case_vrf_staticroute.yaml b/cosmo/tests/test_case_vrf_staticroute.yaml index 5455589..c711761 100644 --- a/cosmo/tests/test_case_vrf_staticroute.yaml +++ b/cosmo/tests/test_case_vrf_staticroute.yaml @@ -88,7 +88,7 @@ device_list: lag: null mac_address: null mode: null - mtu: 9500 + mtu: 9600 name: et-0/0/2.0 tagged_vlans: [] tags: diff --git a/cosmo/tests/test_netboxclient.py b/cosmo/tests/test_netboxclient.py index 8c9a88f..9f10205 100644 --- a/cosmo/tests/test_netboxclient.py +++ b/cosmo/tests/test_netboxclient.py @@ -1,4 +1,5 @@ import pytest +from packaging.version import Version import cosmo.tests.utils as utils from cosmo.clients.netbox import NetboxClient @@ -26,7 +27,7 @@ def test_case_get_data(mocker): [getMock, postMock] = utils.RequestResponseMock.patchNetboxClient(mocker) nc = NetboxClient(TEST_URL, TEST_TOKEN) - assert nc.version == "4.1.2" + assert nc.base_version == Version("4.1.2") getMock.assert_called_once() diff --git a/cosmo/tests/utils.py b/cosmo/tests/utils.py index 77d6e20..bf8690f 100644 --- a/cosmo/tests/utils.py +++ b/cosmo/tests/utils.py @@ -41,7 +41,7 @@ def patchNetboxClient(mocker, **patchKwArgs): def patchGetFunc(url, **kwargs): if "/api/status" in url: - return ResponseMock(200, {"netbox-version": "4.1.2"}) + return ResponseMock(200, {"netbox-version": "4.1.2+wobcom_0.4.2"}) return ResponseMock(200, { "next": None,