diff options
author | Scott Moser <smoser@brickies.net> | 2017-03-31 13:55:27 -0400 |
---|---|---|
committer | Scott Moser <smoser@brickies.net> | 2017-03-31 14:12:57 -0400 |
commit | 5442b517ebe5508159a46d11d500fbc6ad854ba0 (patch) | |
tree | b46ac60342c307decba55231f2889a089b9ee4d0 /tests/unittests/test_datasource/test_digitalocean.py | |
parent | d23543eb206326a53a59d86afba862edbd02c231 (diff) | |
download | vyos-cloud-init-5442b517ebe5508159a46d11d500fbc6ad854ba0.tar.gz vyos-cloud-init-5442b517ebe5508159a46d11d500fbc6ad854ba0.zip |
tests: update OpenNebula and Digital Ocean to not rely on host interfaces.
Mock the use use of get_interfaces_by_mac in Digital Ocean and OpenNebula.
Its best to mock this for the tests as the results aren't expecting
it to fail.
Note, as it stands, OpenNebula relies on devices named 'eth0'.
The metadata (context) does not provide mac addresses.
Diffstat (limited to 'tests/unittests/test_datasource/test_digitalocean.py')
-rw-r--r-- | tests/unittests/test_datasource/test_digitalocean.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/unittests/test_datasource/test_digitalocean.py b/tests/unittests/test_datasource/test_digitalocean.py index 9be6bc19..61d6e001 100644 --- a/tests/unittests/test_datasource/test_digitalocean.py +++ b/tests/unittests/test_datasource/test_digitalocean.py @@ -194,7 +194,12 @@ class TestDataSourceDigitalOcean(TestCase): class TestNetworkConvert(TestCase): - def _get_networking(self): + @mock.patch('cloudinit.net.get_interfaces_by_mac') + def _get_networking(self, m_get_by_mac): + m_get_by_mac.return_value = { + '04:01:57:d1:9e:01': 'ens1', '04:01:57:d1:9e:02': 'ens2', + 'b8:ae:ed:75:5f:9a': 'enp0s25', + 'ae:cc:08:7c:88:00': 'meta2p1'} netcfg = digitalocean.convert_network_configuration( DO_META['interfaces'], DO_META['dns']['nameservers']) self.assertIn('config', netcfg) @@ -302,10 +307,15 @@ class TestNetworkConvert(TestCase): self.assertEqual(ipv4_def.get('netmask'), subn_def.get('netmask')) self.assertNotIn('gateway', subn_def) - def test_convert_without_private(self): + @mock.patch('cloudinit.net.get_interfaces_by_mac') + def test_convert_without_private(self, m_get_by_mac): + m_get_by_mac.return_value = { + 'b8:ae:ed:75:5f:9a': 'enp0s25', + 'ae:cc:08:7c:88:00': 'meta2p1'} netcfg = digitalocean.convert_network_configuration( DO_META_2['interfaces'], DO_META_2['dns']['nameservers']) + # print(netcfg) byname = {} for i in netcfg['config']: if 'name' in i: |