Skip to content
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

Write unit tests for validation methods #55994

Closed
3 of 7 tasks
samdoran opened this issue May 1, 2019 · 1 comment · Fixed by #75061
Closed
3 of 7 tasks

Write unit tests for validation methods #55994

samdoran opened this issue May 1, 2019 · 1 comment · Fixed by #75061
Labels
affects_2.9 This issue/PR affects Ansible v2.9 feature This issue/PR relates to a feature request. has_pr This issue has an associated PR. support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@samdoran
Copy link
Contributor

samdoran commented May 1, 2019

SUMMARY

The argument spec validation methods were moved out of basic.py in Ansible 2.8 to make them available for user outside of AnsibleModule. I got several of the unit tests written but not all of them. I'm mainly documenting this here so we can work on them during PyCon 2019 sprints.

  • check_mutually_exclusive()
  • check_required_one_of()
  • check_required_together()
  • check_required_by()
  • check_required_arguments()
  • check_required_if()
  • fail_on_missing_params()
ISSUE TYPE
  • Feature Idea
COMPONENT NAME

lib/ansible/module_utils/common/validation.py

ADDITIONAL INFORMATION

There may be a bug in check _type_int() that needs fixing and updating the test. If an bool it returns a bool. This is because Python considers True and False integer_types. It seems wrong to me that check_type_int(False) returns False. This has been the behaviour of this method for quite some time, so changing this could have negative effects.

@samdoran samdoran added the pycon_sprints Items that will be worked on during PyCon sprints label May 1, 2019
@ansibot
Copy link
Contributor

ansibot commented May 1, 2019

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibot ansibot added affects_2.9 This issue/PR affects Ansible v2.9 feature This issue/PR relates to a feature request. needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels May 1, 2019
@samdoran samdoran removed the needs_triage Needs a first human triage before being processed. label May 1, 2019
@samdoran samdoran removed pycon_sprints Items that will be worked on during PyCon sprints labels May 31, 2019
@ansibot ansibot added the has_pr This issue has an associated PR. label Dec 11, 2020
Akasurde added a commit to Akasurde/ansible that referenced this issue Jun 20, 2021
* check_required_one_of()
* check_required_by()
* check_required_if()
* check_missing_parameters()

Fixes: ansible#55994

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
mkrizek pushed a commit that referenced this issue Jun 22, 2021
* check_required_one_of()
* check_required_by()
* check_required_if()
* check_missing_parameters()

Fixes: #55994

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
@ansible ansible locked and limited conversation to collaborators Jul 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.9 This issue/PR affects Ansible v2.9 feature This issue/PR relates to a feature request. has_pr This issue has an associated PR. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants