Skip to content

Commit

Permalink
tests: add missing mocks for get_interfaces_by_mac (#326)
Browse files Browse the repository at this point in the history
We currently have a test system where get_interfaces_by_mac raises an
exception, which is causing these tests to fail as they aren't mocking
get_interfaces_by_mac out.

LP: #1873910
  • Loading branch information
OddBloke authored Apr 20, 2020
1 parent 0c5c736 commit d7cad8b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cloudinit/sources/tests/test_oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ def test_with_userdata(self, m_is_iscsi_root):
self.assertEqual(self.my_md['uuid'], ds.get_instance_id())
self.assertEqual(my_userdata, ds.userdata_raw)

@mock.patch(DS_PATH + ".get_interfaces_by_mac", mock.Mock(return_value={}))
@mock.patch(DS_PATH + "._add_network_config_from_opc_imds",
side_effect=lambda network_config: network_config)
@mock.patch(DS_PATH + ".cmdline.read_initramfs_config")
Expand All @@ -207,6 +208,7 @@ def test_network_cmdline(self, m_is_iscsi_root, m_initramfs_config,
self.assertEqual([mock.call()], m_initramfs_config.call_args_list)
self.assertFalse(distro.generate_fallback_config.called)

@mock.patch(DS_PATH + ".get_interfaces_by_mac", mock.Mock(return_value={}))
@mock.patch(DS_PATH + "._add_network_config_from_opc_imds",
side_effect=lambda network_config: network_config)
@mock.patch(DS_PATH + ".cmdline.read_initramfs_config")
Expand Down
1 change: 1 addition & 0 deletions tests/unittests/test_datasource/test_opennebula.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ def my_devs_with(criteria):
util.find_devs_with = orig_find_devs_with


@mock.patch(DS_PATH + '.net.get_interfaces_by_mac', mock.Mock(return_value={}))
class TestOpenNebulaNetwork(unittest.TestCase):

system_nics = ('eth0', 'ens3')
Expand Down

0 comments on commit d7cad8b

Please sign in to comment.