summaryrefslogtreecommitdiff
path: root/tests/unittests
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2016-07-13 22:29:00 -0400
committerScott Moser <smoser@ubuntu.com>2016-07-13 22:29:00 -0400
commit150d064b5693c7a287790900923b9413fe6d73dd (patch)
tree9795460fa9137346f8ef0a918d32e372a97d7ec5 /tests/unittests
parente1d68c11c44ab11acf3f7b234a1db45d85ae19de (diff)
parent7d58c949c2f5d7821ec664ed25167dfea92964f7 (diff)
downloadvyos-cloud-init-150d064b5693c7a287790900923b9413fe6d73dd.tar.gz
vyos-cloud-init-150d064b5693c7a287790900923b9413fe6d73dd.zip
merge from trunk.lp1602373
this merges in the render_hwaddress support. newly added tests still run, so hwaddress seems correctly getting in.
Diffstat (limited to 'tests/unittests')
-rw-r--r--tests/unittests/test_net.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
index ee9061a9..41b9a6d0 100644
--- a/tests/unittests/test_net.py
+++ b/tests/unittests/test_net.py
@@ -549,6 +549,37 @@ iface eth1000 inet dhcp
self.assertEqual(expected.lstrip(), contents.lstrip())
+class TestEniNetworkStateToEni(TestCase):
+ mycfg = {
+ 'config': [{"type": "physical", "name": "eth0",
+ "mac_address": "c0:d6:9f:2c:e8:80",
+ "subnets": [{"type": "dhcp"}]}],
+ 'version': 1}
+ my_mac = 'c0:d6:9f:2c:e8:80'
+
+ def test_no_header(self):
+ rendered = eni.network_state_to_eni(
+ network_state=network_state.parse_net_config_data(self.mycfg),
+ render_hwaddress=True)
+ self.assertIn(self.my_mac, rendered)
+ self.assertIn("hwaddress", rendered)
+
+ def test_with_header(self):
+ header = "# hello world\n"
+ rendered = eni.network_state_to_eni(
+ network_state=network_state.parse_net_config_data(self.mycfg),
+ header=header, render_hwaddress=True)
+ self.assertIn(header, rendered)
+ self.assertIn(self.my_mac, rendered)
+
+ def test_no_hwaddress(self):
+ rendered = eni.network_state_to_eni(
+ network_state=network_state.parse_net_config_data(self.mycfg),
+ render_hwaddress=False)
+ self.assertNotIn(self.my_mac, rendered)
+ self.assertNotIn("hwaddress", rendered)
+
+
class TestCmdlineConfigParsing(TestCase):
simple_cfg = {
'config': [{"type": "physical", "name": "eth0",