Skip to content

Commit

Permalink
unit_tests: fix netaddr ipv6 checks
Browse files Browse the repository at this point in the history
With netaddr version >=1.3.0, the checks for IP addresses contain a type
check, this failing on sentinel values as the type is not supported.
.
Replace the sentinel values with string values.
Change-Id: I1c6440e412919f38ee93dc9f361dc86a12ab605c
  • Loading branch information
ader1990 committed Nov 26, 2024
1 parent aeeca0a commit 8865a51
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions cloudbaseinit/tests/plugins/common/test_networkconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def test_execute_missing_address_netmask6(self):
def test_execute_missing_gateway(self):
self._test_execute_missing_smth(gateway=True)

def _get_network_details_v2(self):
def _get_network_details_v2(self, dns1, dns3):
links = []
link1 = network_model.Link(
id=mock.sentinel.link_id1,
Expand Down Expand Up @@ -359,7 +359,7 @@ def _get_network_details_v2(self):

services = []
service1 = network_model.NameServerService(
addresses=[mock.sentinel.dns1, mock.sentinel.dns3],
addresses=[dns1, dns3],
search=mock.sentinel.dns_search1)
services.append(service1)

Expand All @@ -377,27 +377,33 @@ def _test_execute_network_details_v2(self, mock_get_os_utils,
mock.sentinel.network_cidr2 = u"172.16.0.0/16"
mock.sentinel.gateway2 = u"172.16.1.1"
mock.sentinel.address_cidr1 = u"10.0.0.1/24"
mock.sentinel.dns1 = "10.0.0.1"
dns1 = "10.0.0.1"
dns3 = "10.0.0.3"
dns3_ipv6 = "2001:db8::3"
dns3_ipv6_v2 = "2001:db8::4"
mock.sentinel.dns1 = dns1
mock.sentinel.dns2 = "10.0.0.2"
mock.sentinel.network_dns_list1 = []

if empty_network_dns_list:
mock.sentinel.dns3 = "10.0.0.3"
mock.sentinel.dns3 = dns3
expected_dns_list = [mock.sentinel.dns1, mock.sentinel.dns3]
elif both_ipv4_dns_list:
mock.sentinel.dns3 = "2001:db8::3"
mock.sentinel.dns3 = dns3_ipv6
expected_dns_list = [mock.sentinel.dns1]
dns3 = dns3_ipv6
elif both_ipv6_dns_list:
mock.sentinel.address_cidr1 = u"2001:db8::3/24"
mock.sentinel.dns3 = "2001:db8::4"
mock.sentinel.dns3 = dns3_ipv6_v2
dns3 = dns3_ipv6_v2
expected_dns_list = [mock.sentinel.dns3]
else:
mock.sentinel.network_dns_list1 = [
mock.sentinel.dns1, mock.sentinel.dns2]
expected_dns_list = mock.sentinel.network_dns_list1

service = mock.Mock()
network_details = self._get_network_details_v2()
network_details = self._get_network_details_v2(dns1, dns3)
service.get_network_details_v2.return_value = network_details

mock_os_utils = mock.Mock()
Expand Down

0 comments on commit 8865a51

Please sign in to comment.