From e4cc5c138f09e8e5b49299e548f99853bc3da3a1 Mon Sep 17 00:00:00 2001 From: Till Maas Date: Fri, 17 Feb 2023 23:27:29 +0100 Subject: [PATCH] Unit tests/initscripts: Support checking warnings Signed-off-by: Till Maas --- tests/unit/test_network_connections.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/unit/test_network_connections.py b/tests/unit/test_network_connections.py index becbd49..f55ff0e 100644 --- a/tests/unit/test_network_connections.py +++ b/tests/unit/test_network_connections.py @@ -317,13 +317,19 @@ class TestValidator(Python26CompatTestCase): content_current = kwargs.get("initscripts_content_current", None) if content_current: content_current = content_current[idx] - c = IfcfgUtil.ifcfg_create( - connections, idx, content_current=content_current + warnings = [] + config = IfcfgUtil.ifcfg_create( + connections, + idx, + content_current=content_current, + warn_fcn=warnings.append, ) # pprint("con[%s] = \"%s\"" % (idx, connections[idx]['name']), c) - exp = kwargs.get("initscripts_dict_expected", None) - if exp is not None: - self.assertEqual(exp[idx], c) + expected_config = kwargs.get("initscripts_dict_expected", None) + if expected_config is not None: + self.assertEqual(expected_config[idx], config) + expected_warnings = kwargs.get("initscripts_expected_warnings", []) + self.assertEqual(expected_warnings, warnings) def do_connections_validate( self, expected_connections, input_connections, **kwargs