summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Watkins <oddbloke@ubuntu.com>2020-04-20 14:50:37 -0400
committerGitHub <noreply@github.com>2020-04-20 14:50:37 -0400
commitd7cad8b61a3b5929a65202e0964aa9b4624e06c4 (patch)
tree58618b95d177be1ac828c0931813ba61f75c0d63
parent0c5c736727d0f8e363678fe970d70bb889e3893c (diff)
downloadvyos-cloud-init-d7cad8b61a3b5929a65202e0964aa9b4624e06c4.tar.gz
vyos-cloud-init-d7cad8b61a3b5929a65202e0964aa9b4624e06c4.zip
tests: add missing mocks for get_interfaces_by_mac (#326)
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
-rw-r--r--cloudinit/sources/tests/test_oracle.py2
-rw-r--r--tests/unittests/test_datasource/test_opennebula.py1
2 files changed, 3 insertions, 0 deletions
diff --git a/cloudinit/sources/tests/test_oracle.py b/cloudinit/sources/tests/test_oracle.py
index 4e135df9..2265327b 100644
--- a/cloudinit/sources/tests/test_oracle.py
+++ b/cloudinit/sources/tests/test_oracle.py
@@ -186,6 +186,7 @@ class TestDataSourceOracle(test_helpers.CiTestCase):
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")
@@ -207,6 +208,7 @@ class TestDataSourceOracle(test_helpers.CiTestCase):
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")
diff --git a/tests/unittests/test_datasource/test_opennebula.py b/tests/unittests/test_datasource/test_opennebula.py
index bb399f6d..de896a9e 100644
--- a/tests/unittests/test_datasource/test_opennebula.py
+++ b/tests/unittests/test_datasource/test_opennebula.py
@@ -355,6 +355,7 @@ class TestOpenNebulaDataSource(CiTestCase):
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')