diff options
Diffstat (limited to 'tests/unittests/distros/test_photon.py')
-rw-r--r-- | tests/unittests/distros/test_photon.py | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/tests/unittests/distros/test_photon.py b/tests/unittests/distros/test_photon.py index 3858f723..fed30c2b 100644 --- a/tests/unittests/distros/test_photon.py +++ b/tests/unittests/distros/test_photon.py @@ -1,34 +1,34 @@ # This file is part of cloud-init. See LICENSE file for license information. -from . import _get_distro from cloudinit import util -from tests.unittests.helpers import mock -from tests.unittests.helpers import CiTestCase +from tests.unittests.helpers import CiTestCase, mock + +from . import _get_distro SYSTEM_INFO = { - 'paths': { - 'cloud_dir': '/var/lib/cloud/', - 'templates_dir': '/etc/cloud/templates/', + "paths": { + "cloud_dir": "/var/lib/cloud/", + "templates_dir": "/etc/cloud/templates/", }, - 'network': {'renderers': 'networkd'}, + "network": {"renderers": "networkd"}, } class TestPhoton(CiTestCase): with_logs = True - distro = _get_distro('photon', SYSTEM_INFO) - expected_log_line = 'Rely on PhotonOS default network config' + distro = _get_distro("photon", SYSTEM_INFO) + expected_log_line = "Rely on PhotonOS default network config" def test_network_renderer(self): - self.assertEqual(self.distro._cfg['network']['renderers'], 'networkd') + self.assertEqual(self.distro._cfg["network"]["renderers"], "networkd") def test_get_distro(self): - self.assertEqual(self.distro.osfamily, 'photon') + self.assertEqual(self.distro.osfamily, "photon") @mock.patch("cloudinit.distros.photon.subp.subp") def test_write_hostname(self, m_subp): - hostname = 'myhostname' - hostfile = self.tmp_path('previous-hostname') + hostname = "myhostname" + hostfile = self.tmp_path("previous-hostname") self.distro._write_hostname(hostname, hostfile) self.assertEqual(hostname, util.load_file(hostfile)) @@ -36,7 +36,7 @@ class TestPhoton(CiTestCase): self.assertEqual(ret, hostname) m_subp.return_value = (None, None) - hostfile += 'hostfile' + hostfile += "hostfile" self.distro._write_hostname(hostname, hostfile) m_subp.return_value = (hostname, None) @@ -44,25 +44,25 @@ class TestPhoton(CiTestCase): self.assertEqual(ret, hostname) self.logs.truncate(0) - m_subp.return_value = (None, 'bla') + m_subp.return_value = (None, "bla") self.distro._write_hostname(hostname, None) - self.assertIn('Error while setting hostname', self.logs.getvalue()) + self.assertIn("Error while setting hostname", self.logs.getvalue()) - @mock.patch('cloudinit.net.generate_fallback_config') + @mock.patch("cloudinit.net.generate_fallback_config") def test_fallback_netcfg(self, m_fallback_cfg): - key = 'disable_fallback_netcfg' + key = "disable_fallback_netcfg" # Don't use fallback if no setting given self.logs.truncate(0) - assert(self.distro.generate_fallback_config() is None) + assert self.distro.generate_fallback_config() is None self.assertIn(self.expected_log_line, self.logs.getvalue()) self.logs.truncate(0) self.distro._cfg[key] = True - assert(self.distro.generate_fallback_config() is None) + assert self.distro.generate_fallback_config() is None self.assertIn(self.expected_log_line, self.logs.getvalue()) self.logs.truncate(0) self.distro._cfg[key] = False - assert(self.distro.generate_fallback_config() is not None) + assert self.distro.generate_fallback_config() is not None self.assertNotIn(self.expected_log_line, self.logs.getvalue()) |