From 2b37c8df8d13178c5734681ec8090f055f92caa9 Mon Sep 17 00:00:00 2001 From: cecinestpasunepipe <110607403+cecinestpasunepipe@users.noreply.github.com> Date: Wed, 4 Sep 2024 09:30:45 +0200 Subject: [PATCH] Add unittest --- tests/tools/test_utils.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/tools/test_utils.py b/tests/tools/test_utils.py index d7066dbc0..db5975014 100644 --- a/tests/tools/test_utils.py +++ b/tests/tools/test_utils.py @@ -8,6 +8,7 @@ from dissect.target.plugin import arg, find_plugin_functions from dissect.target.tools.utils import ( args_to_uri, + generate_argparse_for_unbound_method, get_target_attribute, persist_execution_report, ) @@ -77,3 +78,17 @@ def test_plugin_name_confusion_regression(target_unix_users, pattern, expected_f get_target_attribute(target_unix_users, plugins[0]) assert expected_function in str(exc_info.value) + + +def test_plugin_mutual_exclusive_arguments(): + fargs = [ + (("--aa",), {"group": "aa"}), + (("--bb",), {"group": "aa"}), + (("--cc",), {"group": "bb"}), + (("--dd",), {"group": "bb"}), + ] + method = test_plugin_mutual_exclusive_arguments + setattr(method, "__args__", fargs) + with patch("inspect.isfunction", return_value=True): + parser = generate_argparse_for_unbound_method(method) + assert len(parser._mutually_exclusive_groups) == 2