Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
johannwagner committed Jan 17, 2025
1 parent 6c21895 commit 377af7f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions cosmo/clients/netbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion cosmo/tests/test_case_vrf_staticroute.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion cosmo/tests/test_netboxclient.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
from packaging.version import Version

import cosmo.tests.utils as utils
from cosmo.clients.netbox import NetboxClient
Expand Down Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion cosmo/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 377af7f

Please sign in to comment.