Skip to content

Commit

Permalink
Add unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
cecinestpasunepipe committed Sep 4, 2024
1 parent 256482f commit 2b37c8d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/tools/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -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

0 comments on commit 2b37c8d

Please sign in to comment.