-
Notifications
You must be signed in to change notification settings - Fork 346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve unit test coverage of module_utils.policy #1136
Improve unit test coverage of module_utils.policy #1136
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
2fa6797
to
c1b77b6
Compare
This comment was marked as resolved.
This comment was marked as resolved.
…ble_policy slightly
c1b77b6
to
af4171a
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
recheck |
if isinstance(tupleified, list): | ||
tupleified = tuple(tupleified) | ||
hashed_policy = _hashable_policy(each, []) | ||
tupleified = _tuplify_list(hashed_policy) | ||
policy_list.append(tupleified) | ||
elif isinstance(policy, string_types) or isinstance(policy, binary_type): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can write this like this: elif isinstance(policy, (binary_type, string_types)):
>>> a = True
>>> isinstance(a, (int, bool))
True
>>> a = 1
>>> isinstance(a, (int, bool))
True
>>> a = "a string"
>>> isinstance(a, (int, bool))
False
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I'm always feel a bit intimidated by this _hashable_policy()
function :-).
SUMMARY
_hashable_policy
to reduce complexity (and make testing easier)sort_json_policy_dict
, it's very naive and was only used by ecs_ecrISSUE TYPE
COMPONENT NAME
plugins/module_utils/policy.py
ADDITIONAL INFORMATION