summaryrefslogtreecommitdiff
path: root/tests/unittests/cmd/devel/test_hotplug_hook.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unittests/cmd/devel/test_hotplug_hook.py')
-rw-r--r--tests/unittests/cmd/devel/test_hotplug_hook.py24
1 files changed, 17 insertions, 7 deletions
diff --git a/tests/unittests/cmd/devel/test_hotplug_hook.py b/tests/unittests/cmd/devel/test_hotplug_hook.py
index 63d2490e..e1c64e2f 100644
--- a/tests/unittests/cmd/devel/test_hotplug_hook.py
+++ b/tests/unittests/cmd/devel/test_hotplug_hook.py
@@ -30,6 +30,11 @@ def mocks():
return_value=FAKE_MAC
)
+ update_event_enabled = mock.patch(
+ 'cloudinit.stages.update_event_enabled',
+ return_value=True,
+ )
+
m_network_state = mock.MagicMock(spec=NetworkState)
parse_net = mock.patch(
'cloudinit.cmd.devel.hotplug_hook.parse_net_config_data',
@@ -45,6 +50,7 @@ def mocks():
sleep = mock.patch('time.sleep')
read_sys_net.start()
+ update_event_enabled.start()
parse_net.start()
select_activator.start()
m_sleep = sleep.start()
@@ -57,6 +63,7 @@ def mocks():
)
read_sys_net.stop()
+ update_event_enabled.stop()
parse_net.stop()
select_activator.stop()
sleep.stop()
@@ -122,13 +129,16 @@ class TestHotplug:
def test_update_event_disabled(self, mocks, caplog):
init = mocks.m_init
- init.update_event_enabled.return_value = False
- handle_hotplug(
- hotplug_init=init,
- devpath='/dev/fake',
- udevaction='remove',
- subsystem='net'
- )
+ with mock.patch(
+ 'cloudinit.stages.update_event_enabled',
+ return_value=False
+ ):
+ handle_hotplug(
+ hotplug_init=init,
+ devpath='/dev/fake',
+ udevaction='remove',
+ subsystem='net'
+ )
assert 'hotplug not enabled for event of type' in caplog.text
init.datasource.update_metadata_if_supported.assert_not_called()
mocks.m_activator.bring_up_interface.assert_not_called()