summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/ansible-test-sanity/ansible_collections/ns
diff options
context:
space:
mode:
Diffstat (limited to 'test/integration/targets/ansible-test-sanity/ansible_collections/ns')
-rw-r--r--test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/README.rst3
-rw-r--r--test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/galaxy.yml6
-rw-r--r--test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/meta/runtime.yml5
-rw-r--r--test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/filter/check_pylint.py23
-rw-r--r--test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/lookup/bad.py31
-rw-r--r--test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/lookup/world.py29
-rw-r--r--test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/module_utils/__init__.py0
-rw-r--r--test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/modules/bad.py34
-rw-r--r--test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/random_directory/bad.py8
-rw-r--r--test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/tests/integration/targets/hello/files/bad.py16
-rw-r--r--test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/tests/sanity/ignore.txt6
11 files changed, 161 insertions, 0 deletions
diff --git a/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/README.rst b/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/README.rst
new file mode 100644
index 0000000..d8138d3
--- /dev/null
+++ b/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/README.rst
@@ -0,0 +1,3 @@
+README
+------
+This is a simple collection used to verify that ``ansible-test`` works on a collection.
diff --git a/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/galaxy.yml b/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/galaxy.yml
new file mode 100644
index 0000000..08a32e8
--- /dev/null
+++ b/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/galaxy.yml
@@ -0,0 +1,6 @@
+namespace: ns
+name: col
+version: 1.0.0
+readme: README.rst
+authors:
+ - Ansible
diff --git a/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/meta/runtime.yml b/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/meta/runtime.yml
new file mode 100644
index 0000000..fee22ad
--- /dev/null
+++ b/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/meta/runtime.yml
@@ -0,0 +1,5 @@
+requires_ansible: '>=2.11' # force ansible-doc to check the Ansible version (requires packaging)
+plugin_routing:
+ modules:
+ hi:
+ redirect: hello
diff --git a/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/filter/check_pylint.py b/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/filter/check_pylint.py
new file mode 100644
index 0000000..f1be4f3
--- /dev/null
+++ b/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/filter/check_pylint.py
@@ -0,0 +1,23 @@
+"""
+These test cases verify ansible-test version constraints for pylint and its dependencies across Python versions.
+The initial test cases were discovered while testing various Python versions against ansible/ansible.
+"""
+from __future__ import absolute_import, division, print_function
+__metaclass__ = type
+
+# Python 3.8 fails with astroid 2.2.5 but works on 2.3.3
+# syntax-error: Cannot import 'string' due to syntax error 'invalid syntax (<unknown>, line 109)'
+# Python 3.9 fails with astroid 2.2.5 but works on 2.3.3
+# syntax-error: Cannot import 'string' due to syntax error 'invalid syntax (<unknown>, line 104)'
+import string
+
+# Python 3.9 fails with pylint 2.3.1 or 2.4.4 with astroid 2.3.3 but works with pylint 2.5.0 and astroid 2.4.0
+# 'Call' object has no attribute 'value'
+result = {None: None}[{}.get('something')]
+
+# pylint 2.3.1 and 2.4.4 report the following error but 2.5.0 and 2.6.0 do not
+# blacklisted-name: Black listed name "foo"
+# see: https://github.com/PyCQA/pylint/issues/3701
+# regression: documented as a known issue and removed from ignore.txt so pylint can be upgraded to 2.6.0
+# if future versions of pylint fix this issue then the ignore should be restored
+foo = {}.keys()
diff --git a/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/lookup/bad.py b/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/lookup/bad.py
new file mode 100644
index 0000000..580f9d8
--- /dev/null
+++ b/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/lookup/bad.py
@@ -0,0 +1,31 @@
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import absolute_import, division, print_function
+__metaclass__ = type
+
+DOCUMENTATION = '''
+name: bad
+short_description: Bad lookup
+description: A bad lookup.
+author:
+ - Ansible Core Team
+'''
+
+EXAMPLES = '''
+- debug:
+ msg: "{{ lookup('ns.col.bad') }}"
+'''
+
+RETURN = ''' # '''
+
+from ansible.plugins.lookup import LookupBase
+from ansible import constants
+
+import lxml
+
+
+class LookupModule(LookupBase):
+ def run(self, terms, variables, **kwargs):
+ self.set_options(var_options=variables, direct=kwargs)
+
+ return terms
diff --git a/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/lookup/world.py b/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/lookup/world.py
new file mode 100644
index 0000000..dbb479a
--- /dev/null
+++ b/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/lookup/world.py
@@ -0,0 +1,29 @@
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import absolute_import, division, print_function
+__metaclass__ = type
+
+DOCUMENTATION = '''
+name: world
+short_description: World lookup
+description: A world lookup.
+author:
+ - Ansible Core Team
+'''
+
+EXAMPLES = '''
+- debug:
+ msg: "{{ lookup('ns.col.world') }}"
+'''
+
+RETURN = ''' # '''
+
+from ansible.plugins.lookup import LookupBase
+from ansible import constants
+
+
+class LookupModule(LookupBase):
+ def run(self, terms, variables, **kwargs):
+ self.set_options(var_options=variables, direct=kwargs)
+
+ return terms
diff --git a/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/module_utils/__init__.py b/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/module_utils/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/module_utils/__init__.py
diff --git a/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/modules/bad.py b/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/modules/bad.py
new file mode 100644
index 0000000..e79613b
--- /dev/null
+++ b/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/modules/bad.py
@@ -0,0 +1,34 @@
+#!/usr/bin/python
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import absolute_import, division, print_function
+__metaclass__ = type
+
+DOCUMENTATION = '''
+module: bad
+short_description: Bad test module
+description: Bad test module.
+author:
+ - Ansible Core Team
+'''
+
+EXAMPLES = '''
+- bad:
+'''
+
+RETURN = ''''''
+
+from ansible.module_utils.basic import AnsibleModule
+from ansible import constants # intentionally trigger pylint ansible-bad-module-import error
+
+
+def main():
+ module = AnsibleModule(
+ argument_spec=dict(),
+ )
+
+ module.exit_json()
+
+
+if __name__ == '__main__':
+ main()
diff --git a/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/random_directory/bad.py b/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/random_directory/bad.py
new file mode 100644
index 0000000..2e35cf8
--- /dev/null
+++ b/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/random_directory/bad.py
@@ -0,0 +1,8 @@
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import absolute_import, division, print_function
+__metaclass__ = type
+
+# This is not an allowed import, but since this file is in a plugins/ subdirectory that is not checked,
+# the import sanity test will not complain.
+import lxml
diff --git a/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/tests/integration/targets/hello/files/bad.py b/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/tests/integration/targets/hello/files/bad.py
new file mode 100644
index 0000000..8221543
--- /dev/null
+++ b/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/tests/integration/targets/hello/files/bad.py
@@ -0,0 +1,16 @@
+from __future__ import absolute_import, division, print_function
+__metaclass__ = type
+
+import tempfile
+
+try:
+ import urllib2 # intentionally trigger pylint ansible-bad-import error
+except ImportError:
+ urllib2 = None
+
+try:
+ from urllib2 import Request # intentionally trigger pylint ansible-bad-import-from error
+except ImportError:
+ Request = None
+
+tempfile.mktemp() # intentionally trigger pylint ansible-bad-function error
diff --git a/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/tests/sanity/ignore.txt b/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/tests/sanity/ignore.txt
new file mode 100644
index 0000000..e1b3f4c
--- /dev/null
+++ b/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/tests/sanity/ignore.txt
@@ -0,0 +1,6 @@
+plugins/modules/bad.py import
+plugins/modules/bad.py pylint:ansible-bad-module-import
+plugins/lookup/bad.py import
+tests/integration/targets/hello/files/bad.py pylint:ansible-bad-function
+tests/integration/targets/hello/files/bad.py pylint:ansible-bad-import
+tests/integration/targets/hello/files/bad.py pylint:ansible-bad-import-from