Clean up test failures (#216)
* Fix arguments-renamed * Handle changed behavior in 2.15pull/210/head
parent
57c5cd4336
commit
462e4e7f71
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
trivial:
|
||||||
|
- Fix various 2.15 sanity and unit tests. (https://github.com/ansible-collections/ansible.utils/pull/216)
|
|
@ -303,7 +303,7 @@ from ansible.errors import AnsibleFilterError
|
||||||
from ansible_collections.ansible.utils.plugins.module_utils.common.argspec_validate import (
|
from ansible_collections.ansible.utils.plugins.module_utils.common.argspec_validate import (
|
||||||
AnsibleArgSpecValidator,
|
AnsibleArgSpecValidator,
|
||||||
)
|
)
|
||||||
from ansible_collections.ansible.utils.plugins.module_utils.common.index_of import index_of
|
from ansible_collections.ansible.utils.plugins.plugin_utils.index_of import index_of
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -324,7 +324,7 @@ from ansible.plugins.lookup import LookupBase
|
||||||
from ansible_collections.ansible.utils.plugins.module_utils.common.argspec_validate import (
|
from ansible_collections.ansible.utils.plugins.module_utils.common.argspec_validate import (
|
||||||
AnsibleArgSpecValidator,
|
AnsibleArgSpecValidator,
|
||||||
)
|
)
|
||||||
from ansible_collections.ansible.utils.plugins.module_utils.common.index_of import index_of
|
from ansible_collections.ansible.utils.plugins.plugin_utils.index_of import index_of
|
||||||
|
|
||||||
|
|
||||||
class LookupModule(LookupBase):
|
class LookupModule(LookupBase):
|
||||||
|
|
|
@ -16,6 +16,7 @@ import json
|
||||||
|
|
||||||
from ansible.module_utils._text import to_native
|
from ansible.module_utils._text import to_native
|
||||||
from ansible.module_utils.six import integer_types, string_types
|
from ansible.module_utils.six import integer_types, string_types
|
||||||
|
from jinja2.exceptions import TemplateSyntaxError
|
||||||
|
|
||||||
|
|
||||||
# Note, this file can only be used on the control node
|
# Note, this file can only be used on the control node
|
||||||
|
@ -99,11 +100,17 @@ def _run_test(entry, test, right, tests):
|
||||||
if not isinstance(right, list) and test == "in":
|
if not isinstance(right, list) and test == "in":
|
||||||
right = [right]
|
right = [right]
|
||||||
|
|
||||||
|
# JinjaPluginIntercept.get() raises an exception instead of returning None
|
||||||
|
# in ansible-core 2.15+
|
||||||
|
try:
|
||||||
j2_test = tests.get(test)
|
j2_test = tests.get(test)
|
||||||
|
except TemplateSyntaxError:
|
||||||
|
j2_test = None
|
||||||
|
|
||||||
if not j2_test:
|
if not j2_test:
|
||||||
msg = "{msg} Error was: the test '{test}' was not found.".format(msg=msg, test=test)
|
msg = "{msg} Error was: the test '{test}' was not found.".format(msg=msg, test=test)
|
||||||
_raise_error(msg)
|
_raise_error(msg)
|
||||||
else:
|
|
||||||
try:
|
try:
|
||||||
if right is None:
|
if right is None:
|
||||||
result = j2_test(entry)
|
result = j2_test(entry)
|
|
@ -1 +0,0 @@
|
||||||
plugins/module_utils/common/index_of.py pylint:ansible-bad-module-import # file's use is limited to filter and lookups on control node
|
|
|
@ -1 +0,0 @@
|
||||||
plugins/module_utils/common/index_of.py pylint:ansible-bad-module-import # file's use is limited to filter and lookups on control node
|
|
|
@ -1,2 +0,0 @@
|
||||||
plugins/module_utils/common/index_of.py pylint:ansible-bad-module-import # file's use is limited to filter and lookups on control node
|
|
||||||
tests/unit/mock/loader.py pylint:arguments-renamed
|
|
|
@ -1,2 +0,0 @@
|
||||||
plugins/module_utils/common/index_of.py pylint:ansible-bad-module-import # file's use is limited to filter and lookups on control node
|
|
||||||
tests/unit/mock/loader.py pylint:arguments-renamed
|
|
|
@ -1,2 +0,0 @@
|
||||||
plugins/module_utils/common/index_of.py pylint:ansible-bad-module-import # file's use is limited to filter and lookups on control node
|
|
||||||
tests/unit/mock/loader.py pylint:arguments-renamed
|
|
|
@ -1 +0,0 @@
|
||||||
plugins/module_utils/common/index_of.py pylint:ansible-bad-module-import # file's use is limited to filter and lookups on control node
|
|
|
@ -47,12 +47,12 @@ class DictDataLoader(DataLoader):
|
||||||
|
|
||||||
# TODO: the real _get_file_contents returns a bytestring, so we actually convert the
|
# TODO: the real _get_file_contents returns a bytestring, so we actually convert the
|
||||||
# unicode/text it's created with to utf-8
|
# unicode/text it's created with to utf-8
|
||||||
def _get_file_contents(self, path):
|
def _get_file_contents(self, file_name):
|
||||||
path = to_text(path)
|
file_name = to_text(file_name)
|
||||||
if path in self._file_mapping:
|
if file_name in self._file_mapping:
|
||||||
return (to_bytes(self._file_mapping[path]), False)
|
return (to_bytes(self._file_mapping[file_name]), False)
|
||||||
else:
|
else:
|
||||||
raise AnsibleParserError("file not found: %s" % path)
|
raise AnsibleParserError("file not found: %s" % file_name)
|
||||||
|
|
||||||
def path_exists(self, path):
|
def path_exists(self, path):
|
||||||
path = to_text(path)
|
path = to_text(path)
|
||||||
|
|
|
@ -14,7 +14,7 @@ import unittest
|
||||||
|
|
||||||
from ansible.template import Templar
|
from ansible.template import Templar
|
||||||
|
|
||||||
from ansible_collections.ansible.utils.plugins.module_utils.common.index_of import index_of
|
from ansible_collections.ansible.utils.plugins.plugin_utils.index_of import index_of
|
||||||
|
|
||||||
|
|
||||||
class TestIndexOfFilter(unittest.TestCase):
|
class TestIndexOfFilter(unittest.TestCase):
|
Loading…
Reference in New Issue