summaryrefslogtreecommitdiff
path: root/tests/unittests/test_net_freebsd.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unittests/test_net_freebsd.py')
-rw-r--r--tests/unittests/test_net_freebsd.py45
1 files changed, 24 insertions, 21 deletions
diff --git a/tests/unittests/test_net_freebsd.py b/tests/unittests/test_net_freebsd.py
index f0dde097..3facb2bb 100644
--- a/tests/unittests/test_net_freebsd.py
+++ b/tests/unittests/test_net_freebsd.py
@@ -3,8 +3,7 @@ import os
import cloudinit.net
import cloudinit.net.network_state
from cloudinit import safeyaml
-from tests.unittests.helpers import (CiTestCase, mock, readResource, dir2dict)
-
+from tests.unittests.helpers import CiTestCase, dir2dict, mock, readResource
SAMPLE_FREEBSD_IFCONFIG_OUT = readResource("netinfo/freebsd-ifconfig-output")
V1 = """
@@ -22,34 +21,36 @@ version: 1
class TestInterfacesByMac(CiTestCase):
-
- @mock.patch('cloudinit.subp.subp')
- @mock.patch('cloudinit.util.is_FreeBSD')
+ @mock.patch("cloudinit.subp.subp")
+ @mock.patch("cloudinit.util.is_FreeBSD")
def test_get_interfaces_by_mac(self, mock_is_FreeBSD, mock_subp):
mock_is_FreeBSD.return_value = True
mock_subp.return_value = (SAMPLE_FREEBSD_IFCONFIG_OUT, 0)
a = cloudinit.net.get_interfaces_by_mac()
- assert a == {'52:54:00:50:b7:0d': 'vtnet0',
- '80:00:73:63:5c:48': 're0.33',
- '02:14:39:0e:25:00': 'bridge0',
- '02:ff:60:8c:f3:72': 'vnet0:11'}
+ assert a == {
+ "52:54:00:50:b7:0d": "vtnet0",
+ "80:00:73:63:5c:48": "re0.33",
+ "02:14:39:0e:25:00": "bridge0",
+ "02:ff:60:8c:f3:72": "vnet0:11",
+ }
class TestFreeBSDRoundTrip(CiTestCase):
-
- def _render_and_read(self, network_config=None, state=None,
- netplan_path=None, target=None):
+ def _render_and_read(
+ self, network_config=None, state=None, netplan_path=None, target=None
+ ):
if target is None:
target = self.tmp_dir()
os.mkdir("%s/etc" % target)
- with open("%s/etc/rc.conf" % target, 'a') as fd:
+ with open("%s/etc/rc.conf" % target, "a") as fd:
fd.write("# dummy rc.conf\n")
- with open("%s/etc/resolv.conf" % target, 'a') as fd:
+ with open("%s/etc/resolv.conf" % target, "a") as fd:
fd.write("# dummy resolv.conf\n")
if network_config:
ns = cloudinit.net.network_state.parse_net_config_data(
- network_config)
+ network_config
+ )
elif state:
ns = state
else:
@@ -59,18 +60,20 @@ class TestFreeBSDRoundTrip(CiTestCase):
renderer.render_network_state(ns, target=target)
return dir2dict(target)
- @mock.patch('cloudinit.subp.subp')
+ @mock.patch("cloudinit.subp.subp")
def test_render_output_has_yaml(self, mock_subp):
entry = {
- 'yaml': V1,
+ "yaml": V1,
}
- network_config = safeyaml.load(entry['yaml'])
+ network_config = safeyaml.load(entry["yaml"])
ns = cloudinit.net.network_state.parse_net_config_data(network_config)
files = self._render_and_read(state=ns)
assert files == {
- '/etc/resolv.conf': '# dummy resolv.conf\n',
- '/etc/rc.conf': (
+ "/etc/resolv.conf": "# dummy resolv.conf\n",
+ "/etc/rc.conf": (
"# dummy rc.conf\n"
"ifconfig_eno1="
- "'172.20.80.129 netmask 255.255.255.128 mtu 1470'\n")}
+ "'172.20.80.129 netmask 255.255.255.128 mtu 1470'\n"
+ ),
+ }