Skip to content
Snippets Groups Projects
Commit c17e9fe2 authored by Rafael Guterres Jeffman's avatar Rafael Guterres Jeffman
Browse files

Fix compare_args_ipa when passing None as parameter.

There were no test for the arguments of compare_args_ipa() to check
if they were `None`, and they were used in contexts where `None`
would raise exceptions.

A test was added to return `False` if only one of the parameters is
`None`, and `True` if both are None.
parent eb5463d9
No related branches found
No related tags found
No related merge requests found
...@@ -285,6 +285,23 @@ def compare_args_ipa(module, args, ipa): # noqa ...@@ -285,6 +285,23 @@ def compare_args_ipa(module, args, ipa): # noqa
""" """
base_debug_msg = "Ansible arguments and IPA commands differed. " base_debug_msg = "Ansible arguments and IPA commands differed. "
# If both args and ipa are None, return there's no difference.
# If only one is None, return there is a difference.
# This tests avoid unecessary invalid access to attributes.
if args is None and ipa is None:
return True
if args is None or ipa is None:
module.debug(
base_debug_msg + "args is%s None an ipa is%s None" % (
"" if args is None else " not", "" if ipa is None else " not",
)
)
return False
# Fail if args or ipa are not dicts.
if not (isinstance(args, dict) and isinstance(ipa, dict)):
raise TypeError("Expected 'dicts' to compare.")
for key in args.keys(): for key in args.keys():
if key not in ipa: if key not in ipa:
module.debug( module.debug(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment