issue #217: tests: import (unused) module_utils tests.

pull/245/head
David Wilson 7 years ago
parent ee741da2b3
commit 267f787d20

@ -5,6 +5,7 @@ strategy_plugins = ../../ansible_mitogen/plugins/strategy
action_plugins = lib/action
callback_plugins = lib/callback
library = lib/modules
# module_utils = lib/module_utils
retry_files_enabled = False
forks = 50

@ -8,6 +8,7 @@
- import_playbook: become/all.yml
- import_playbook: connection_loader/all.yml
- import_playbook: context_service/all.yml
#- import_playbook: module_utils/all.yml
- import_playbook: playbook_semantics/all.yml
- import_playbook: remote_tmp/all.yml
- import_playbook: runner/all.yml

@ -0,0 +1,17 @@
# external2 is loaded from config path.
# external1 is loaded from integration/module_utils/module_utils/..
- name: integration/module_utils/adjacent_to_playbook.yml
hosts: test-targets
any_errors_fatal: true
tasks:
- custom_python_external_module:
register: out
- debug: msg={{out}}
- assert:
that:
- out.external1_path == "ansible/integration/module_utils/module_utils/external1.py"
- out.external2_path == "ansible/lib/module_utils/external2.py"

@ -0,0 +1,8 @@
# external2 is loaded from config path.
# external1 is loaded from integration/module_utils/roles/modrole/module_utils/..
- name: integration/module_utils/adjacent_to_playbook.yml
hosts: test-targets
any_errors_fatal: true
roles:
- modrole

@ -0,0 +1,6 @@
- import_playbook: from_config_path.yml
- import_playbook: from_config_path_pkg.yml
- import_playbook: adjacent_to_playbook.yml
- import_playbook: adjacent_to_role.yml
- import_playbook: overrides_builtin.yml

@ -0,0 +1,15 @@
# external1 and external2 are loaded from config path.
- name: integration/module_utils/from_config_path.yml
hosts: test-targets
any_errors_fatal: true
tasks:
- custom_python_external_module:
register: out
- assert:
that:
- out.external1_path == "ansible/lib/module_utils/external1.py"
- out.external2_path == "ansible/lib/module_utils/external2.py"

@ -0,0 +1,14 @@
# external1 and external2 are loaded from config path.
- name: integration/module_utils/from_config_path.yml
hosts: test-targets
any_errors_fatal: true
tasks:
- custom_python_external_pkg:
register: out
- assert:
that:
- out.extmod_path == "ansible/lib/module_utils/externalpkg/extmod.py"

@ -0,0 +1,11 @@
# I am ansible.module_utils.external1 for any module that does not have an
# adjacent module_utils directory overriding the name, since I appear in the
# 'module_utils' path in ansible.cfg.
from ansible.module_utils import external2
def path():
return "ansible/integration/module_utils/module_utils/external1.py"
def path2():
return external2.path()

@ -0,0 +1,6 @@
- name: integration/module_utils/overrides_builtin.yml
hosts: test-targets
any_errors_fatal: true
roles:
- overrides_modrole

@ -0,0 +1,12 @@
#!/usr/bin/python
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils import external3
def main():
module = AnsibleModule(argument_spec={})
module.exit_json(external2_path=external3.path2(),
external3_path=external3.path())
if __name__ == '__main__':
main()

@ -0,0 +1,12 @@
# I am ansible.module_utils.external1 for any module that does not have an
# adjacent module_utils directory overriding the name, since I appear in the
# 'module_utils' path in ansible.cfg.
from ansible.module_utils import external2
def path():
return "ansible/integration/module_utils/roles/modroel/module_utils/external1.py"
def path2():
return external2.path()

@ -0,0 +1,3 @@
def path():
return "integration/module_utils/roles/modrole/module_utils/external2.py"

@ -0,0 +1,12 @@
# I am ansible.module_utils.external1 for any module that does not have an
# adjacent module_utils directory overriding the name, since I appear in the
# 'module_utils' path in ansible.cfg.
from ansible.module_utils import external2
def path():
return "integration/module_utils/roles/modrole/module_utils/external3.py"
def path2():
return external2.path()

@ -0,0 +1,10 @@
---
- uses_external3:
register: out
- debug: msg={{out}}
- assert:
that:
- out.external3_path == "integration/module_utils/roles/modrole/module_utils/external3.py"
- out.external2_path == "integration/module_utils/roles/modrole/module_utils/external2.py"

@ -0,0 +1,12 @@
#!/usr/bin/python
import json
from ansible.module_utils.basic import path
def main():
print json.dumps({
'path': path()
})
if __name__ == '__main__':
main()

@ -0,0 +1,4 @@
# Override basic.py with our own thing.
def path():
return 'ansible/integration/module_utils/roles/override_modrole/module_utils/basic.py'

@ -0,0 +1,9 @@
---
- uses_custom_known_hosts:
register: out
- debug: msg={{out}}
- assert:
that:
- out.path == "ansible/integration/module_utils/roles/override_modrole/module_utils/known_hosts.py"

@ -0,0 +1,11 @@
# I am ansible.module_utils.external1 for any module that does not have an
# adjacent module_utils directory overriding the name, since I appear in the
# 'module_utils' path in ansible.cfg.
from ansible.module_utils import external2
def path():
return "ansible/lib/module_utils/external1.py"
def path2():
return external2.path()

@ -0,0 +1,3 @@
def path():
return "ansible/lib/module_utils/external2.py"

@ -0,0 +1,3 @@
def path():
return 'ansible/lib/module_utils/externalpkg/extmod.py'

@ -0,0 +1,13 @@
#!/usr/bin/python
# I expect the quote from modules2/module_utils/joker.py.
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils import external1
def main():
module = AnsibleModule(argument_spec={})
module.exit_json(external1_path=external1.path(),
external2_path=external1.path2())
if __name__ == '__main__':
main()

@ -0,0 +1,11 @@
#!/usr/bin/python
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.externalpkg import extmod
def main():
module = AnsibleModule(argument_spec={})
module.exit_json(extmod_path=extmod.path())
if __name__ == '__main__':
main()
Loading…
Cancel
Save