Merge "Fix mock of the _is_keepalived_use_no_track_supported"

This commit is contained in:
Zuul 2021-01-28 09:49:59 +00:00 committed by Gerrit Code Review
commit 0fc3a698b3
1 changed files with 28 additions and 13 deletions

View File

@ -194,6 +194,9 @@ class KeepalivedConfTestCase(KeepalivedBaseTestCase,
def test_config_generation_no_track_not_supported(self):
config = self._get_config()
with mock.patch.object(
keepalived, '_is_keepalived_use_no_track_supported',
return_value=False):
self.assertEqual(self.expected.replace(' no_track', ''),
config.get_config_str())
@ -340,6 +343,9 @@ class KeepalivedInstanceRoutesTestCase(KeepalivedBaseTestCase):
return expected
def test_build_config_no_track_not_supported(self):
with mock.patch.object(
keepalived, '_is_keepalived_use_no_track_supported',
return_value=False):
routes = self._get_instance_routes()
self.assertEqual(self._get_no_track_less_expected_config(),
'\n'.join(routes.build_config()))
@ -418,6 +424,9 @@ class KeepalivedInstanceTestCase(KeepalivedBaseTestCase,
self._test_remove_addresses_by_interface(" no_track")
def test_remove_address_by_interface_no_track_not_supported(self):
with mock.patch.object(
keepalived, '_is_keepalived_use_no_track_supported',
return_value=False):
self._test_remove_addresses_by_interface("")
def test_remove_addresses_by_interface_without_no_track(self):
@ -493,6 +502,9 @@ class KeepalivedVirtualRouteTestCase(KeepalivedBaseTestCase):
route.build_config())
def test_virtual_route_with_dev_no_track_not_supported(self):
with mock.patch.object(
keepalived, '_is_keepalived_use_no_track_supported',
return_value=False):
route = keepalived.KeepalivedVirtualRoute(
n_consts.IPv4_ANY, '1.2.3.4', 'eth0')
self.assertEqual('0.0.0.0/0 via 1.2.3.4 dev eth0',
@ -514,6 +526,9 @@ class KeepalivedVirtualRouteTestCase(KeepalivedBaseTestCase):
route.build_config())
def test_virtual_route_without_dev_no_track_not_supported(self):
with mock.patch.object(
keepalived, '_is_keepalived_use_no_track_supported',
return_value=False):
route = keepalived.KeepalivedVirtualRoute('50.0.0.0/8', '1.2.3.4')
self.assertEqual('50.0.0.0/8 via 1.2.3.4',
route.build_config())