summaryrefslogtreecommitdiff
path: root/tests/unittests/test_stages.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unittests/test_stages.py')
-rw-r--r--tests/unittests/test_stages.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/unittests/test_stages.py b/tests/unittests/test_stages.py
index 7fde2bac..15a7e973 100644
--- a/tests/unittests/test_stages.py
+++ b/tests/unittests/test_stages.py
@@ -356,6 +356,26 @@ class TestInit:
) == self.init._find_networking_config()
assert "network config disabled" not in caplog.text
+ @mock.patch(M_PATH + "cmdline.read_initramfs_config", return_value={})
+ @mock.patch(M_PATH + "cmdline.read_kernel_cmdline_config", return_value={})
+ def test_warn_on_empty_network(self, m_cmdline, m_initramfs, caplog):
+ """funky whitespace can lead to a network key that is None, which then
+ causes fallback. Test warning log on empty network key.
+ """
+ m_cmdline.return_value = {} # Kernel doesn't disable networking
+ m_initramfs.return_value = {} # no initramfs network config
+ # Neither datasource nor system_info disable or provide network
+ self.init._cfg = {
+ "system_info": {"paths": {"cloud_dir": self.tmpdir}},
+ "network": None,
+ }
+ self.init.datasource = FakeDataSource(network_config={"network": None})
+
+ self.init.distro.generate_fallback_config = lambda: {}
+
+ self.init._find_networking_config()
+ assert "Empty network config found" in caplog.text
+
def test_apply_network_config_disabled(self, caplog):
"""Log when network is disabled by upgraded-network."""
disable_file = os.path.join(