collection 교체

This commit is contained in:
정훈 변
2024-02-23 16:37:40 +09:00
parent b494779b5b
commit 3fd554eee9
38862 changed files with 220204 additions and 6600073 deletions

View File

@@ -3,39 +3,28 @@
from __future__ import absolute_import, division, print_function
__metaclass__ = type
import os
import tempfile
from ansible.module_utils.connection import ConnectionError as AnsibleConnectionError
from ansible.playbook.task import Task
from ansible.template import Templar
from ansible_collections.ansible.utils.tests.unit.compat import unittest
from ansible_collections.ansible.utils.tests.unit.compat.mock import (
MagicMock,
patch,
)
from ansible_collections.ansible.utils.tests.unit.mock.loader import (
DictDataLoader,
)
from ansible_collections.ansible.utils.plugins.action.cli_parse import (
ARGSPEC_CONDITIONALS,
ActionModule,
)
from ansible_collections.ansible.utils.plugins.modules.cli_parse import (
DOCUMENTATION,
)
from ansible_collections.ansible.utils.plugins.module_utils.common.argspec_validate import (
check_argspec,
)
from ansible_collections.ansible.utils.plugins.action.cli_parse import (
ARGSPEC_CONDITIONALS,
)
from ansible_collections.ansible.utils.plugins.plugin_utils.base.cli_parser import (
CliParserBase,
)
from ansible.module_utils.connection import (
ConnectionError as AnsibleConnectionError,
)
from ansible_collections.ansible.utils.plugins.modules.cli_parse import DOCUMENTATION
from ansible_collections.ansible.utils.plugins.plugin_utils.base.cli_parser import CliParserBase
from ansible_collections.ansible.utils.tests.unit.compat import unittest
from ansible_collections.ansible.utils.tests.unit.compat.mock import MagicMock, patch
from ansible_collections.ansible.utils.tests.unit.mock.loader import DictDataLoader
class TestCli_Parse(unittest.TestCase):
@@ -65,9 +54,7 @@ class TestCli_Parse(unittest.TestCase):
:return: The file contents
:rtype: str
"""
fixture_name = os.path.join(
os.path.dirname(__file__), "fixtures", filename
)
fixture_name = os.path.join(os.path.dirname(__file__), "fixtures", filename)
with open(fixture_name) as fhand:
return fhand.read()
@@ -94,7 +81,10 @@ class TestCli_Parse(unittest.TestCase):
},
}
valid, result, updated_params = check_argspec(
DOCUMENTATION, "cli_parse module", schema_conditionals={}, **kwargs
DOCUMENTATION,
"cli_parse module",
schema_conditionals={},
**kwargs,
)
self.assertEqual(valid, True)
@@ -104,18 +94,16 @@ class TestCli_Parse(unittest.TestCase):
"parser": {
"name": "ansible.utils.textfsm",
"command": "show version",
}
},
}
valid, result, updated_params = check_argspec(
DOCUMENTATION,
"cli_parse module",
schema_conditionals=ARGSPEC_CONDITIONALS,
**kwargs
**kwargs,
)
self.assertIn(
"one of the following is required: command, text", result["errors"]
)
self.assertIn("one of the following is required: command, text", result["errors"])
def test_fn_check_argspec_fail_no_parser_name(self):
"""Confirm failed argspec no parser name"""
@@ -124,7 +112,7 @@ class TestCli_Parse(unittest.TestCase):
DOCUMENTATION,
"cli_parse module",
schema_conditionals=ARGSPEC_CONDITIONALS,
**kwargs
**kwargs,
)
self.assertIn(
"missing required arguments: name found in parser",
@@ -154,9 +142,7 @@ class TestCli_Parse(unittest.TestCase):
}
self._plugin._extended_check_argspec()
self.assertTrue(self._plugin._result["failed"])
self.assertIn(
"provided when parsing text", self._plugin._result["msg"]
)
self.assertIn("provided when parsing text", self._plugin._result["msg"])
def test_fn_load_parser_pass(self):
"""Confirm each each of the parsers loads from the filesystem"""
@@ -191,9 +177,7 @@ class TestCli_Parse(unittest.TestCase):
"parser": {"name": "a.b.c"},
}
self._plugin._set_parser_command()
self.assertEqual(
self._plugin._task.args["parser"]["command"], "anything"
)
self.assertEqual(self._plugin._task.args["parser"]["command"], "anything")
def test_fn_set_parser_command_present(self):
"""Confirm parser/command is not changed if provided"""
@@ -202,9 +186,7 @@ class TestCli_Parse(unittest.TestCase):
"parser": {"command": "something", "name": "a.b.c"},
}
self._plugin._set_parser_command()
self.assertEqual(
self._plugin._task.args["parser"]["command"], "something"
)
self.assertEqual(self._plugin._task.args["parser"]["command"], "something")
def test_fn_set_parser_command_absent(self):
"""Confirm parser/command is not added"""
@@ -244,9 +226,7 @@ class TestCli_Parse(unittest.TestCase):
"""Check the creation of the template_path if
it doesn't exist in the user provided data
"""
self._plugin._task.args = {
"parser": {"command": "a command", "name": "a.b.c"}
}
self._plugin._task.args = {"parser": {"command": "a command", "name": "a.b.c"}}
self._plugin._task_vars = {"ansible_network_os": "cisco.nxos.nxos"}
with self.assertRaises(Exception) as error:
self._plugin._update_template_path("yaml")
@@ -261,7 +241,7 @@ class TestCli_Parse(unittest.TestCase):
name based on os provided in task
"""
self._plugin._task.args = {
"parser": {"command": "a command", "name": "a.b.c", "os": "myos"}
"parser": {"command": "a command", "name": "a.b.c", "os": "myos"},
}
with self.assertRaises(Exception) as error:
self._plugin._update_template_path("yaml")
@@ -276,17 +256,15 @@ class TestCli_Parse(unittest.TestCase):
need to be in the default template folder
"""
template_path = os.path.join(
os.path.dirname(__file__), "fixtures", "nxos_show_version.yaml"
os.path.dirname(__file__),
"fixtures",
"nxos_show_version.yaml",
)
self._plugin._find_needle = MagicMock()
self._plugin._find_needle.return_value = template_path
self._plugin._task.args = {
"parser": {"command": "show version", "os": "nxos"}
}
self._plugin._task.args = {"parser": {"command": "show version", "os": "nxos"}}
self._plugin._update_template_path("yaml")
self.assertEqual(
self._plugin._task.args["parser"]["template_path"], template_path
)
self.assertEqual(self._plugin._task.args["parser"]["template_path"], template_path)
def test_fn_get_template_contents_pass(self):
"""Check the retrieval of the template contents"""
@@ -304,9 +282,7 @@ class TestCli_Parse(unittest.TestCase):
self._plugin._task.args = {"parser": {"template_path": "non-exist"}}
with self.assertRaises(Exception) as error:
self._plugin._get_template_contents()
self.assertIn(
"Failed to open template 'non-exist'", str(error.exception)
)
self.assertIn("Failed to open template 'non-exist'", str(error.exception))
def test_fn_get_template_contents_not_specified(self):
"""Check the none when template_path not specified"""
@@ -364,9 +340,7 @@ class TestCli_Parse(unittest.TestCase):
"""Check run command for network"""
expected = "abc"
mock_rpc.return_value = expected
self._plugin._connection.socket_path = (
tempfile.NamedTemporaryFile().name
)
self._plugin._connection.socket_path = tempfile.NamedTemporaryFile().name
self._plugin._task.args = {"command": "command"}
self._plugin._run_command()
self.assertEqual(self._plugin._result["stdout"], expected)
@@ -383,11 +357,11 @@ class TestCli_Parse(unittest.TestCase):
"""Check full module run with valid params"""
mock_out = self._load_fixture("nxos_show_version.txt")
mock_rpc.return_value = mock_out
self._plugin._connection.socket_path = (
tempfile.NamedTemporaryFile().name
)
self._plugin._connection.socket_path = tempfile.NamedTemporaryFile().name
template_path = os.path.join(
os.path.dirname(__file__), "fixtures", "nxos_show_version.textfsm"
os.path.dirname(__file__),
"fixtures",
"nxos_show_version.textfsm",
)
self._plugin._task.args = {
"command": "show version",
@@ -402,20 +376,18 @@ class TestCli_Parse(unittest.TestCase):
self.assertEqual(result["stdout"], mock_out)
self.assertEqual(result["stdout_lines"], mock_out.splitlines())
self.assertEqual(result["parsed"][0]["version"], "9.2(2)")
self.assertEqual(
result["ansible_facts"]["new_fact"][0]["version"], "9.2(2)"
)
self.assertEqual(result["ansible_facts"]["new_fact"][0]["version"], "9.2(2)")
@patch("ansible.module_utils.connection.Connection.__rpc__")
def test_fn_run_pass_wo_fact(self, mock_rpc):
"""Check full module run with valid params"""
mock_out = self._load_fixture("nxos_show_version.txt")
mock_rpc.return_value = mock_out
self._plugin._connection.socket_path = (
tempfile.NamedTemporaryFile().name
)
self._plugin._connection.socket_path = tempfile.NamedTemporaryFile().name
template_path = os.path.join(
os.path.dirname(__file__), "fixtures", "nxos_show_version.textfsm"
os.path.dirname(__file__),
"fixtures",
"nxos_show_version.textfsm",
)
self._plugin._task.args = {
"command": "show version",
@@ -494,11 +466,11 @@ class TestCli_Parse(unittest.TestCase):
mock_out = self._load_fixture("nxos_show_version.txt")
mock_rpc.return_value = mock_out
self._plugin._connection.socket_path = (
tempfile.NamedTemporaryFile().name
)
self._plugin._connection.socket_path = tempfile.NamedTemporaryFile().name
template_path = os.path.join(
os.path.dirname(__file__), "fixtures", "nxos_empty_parser.textfsm"
os.path.dirname(__file__),
"fixtures",
"nxos_empty_parser.textfsm",
)
self._plugin._task.args = {
"command": "show version",
@@ -530,11 +502,11 @@ class TestCli_Parse(unittest.TestCase):
mock_out = self._load_fixture("nxos_show_version.textfsm")
mock_rpc.return_value = mock_out
self._plugin._connection.socket_path = (
tempfile.NamedTemporaryFile().name
)
self._plugin._connection.socket_path = tempfile.NamedTemporaryFile().name
template_path = os.path.join(
os.path.dirname(__file__), "fixtures", "nxos_empty_parser.textfsm"
os.path.dirname(__file__),
"fixtures",
"nxos_empty_parser.textfsm",
)
self._plugin._task.args = {
"command": "show version",
@@ -553,9 +525,7 @@ class TestCli_Parse(unittest.TestCase):
"""Check full module run mock error from network device"""
msg = "I was mocked"
mock_rpc.side_effect = AnsibleConnectionError(msg)
self._plugin._connection.socket_path = (
tempfile.NamedTemporaryFile().name
)
self._plugin._connection.socket_path = tempfile.NamedTemporaryFile().name
self._plugin._task.args = {
"command": "show version",
"parser": {"name": "ansible.utils.textfsm"},

View File

@@ -5,27 +5,31 @@
from __future__ import absolute_import, division, print_function
__metaclass__ = type
import re
import unittest
from ansible.playbook.task import Task
from ansible.template import Templar
from ansible_collections.ansible.utils.plugins.action.fact_diff import (
ActionModule,
)
from ansible_collections.ansible.utils.plugins.action.fact_diff import ActionModule
try:
from unittest.mock import MagicMock # pylint:disable=syntax-error
except ImportError:
from mock import MagicMock
from mock import MagicMock # pyright: ignore[reportMissingModuleSource]
class TestUpdate_Fact(unittest.TestCase):
def setUp(self):
task = MagicMock(Task)
# Ansible > 2.13 looks for check_mode in task
task.check_mode = False
play_context = MagicMock()
# Ansible <= 2.13 looks for check_mode in play_context
play_context.check_mode = False
connection = MagicMock()
fake_loader = {}
@@ -151,15 +155,9 @@ class TestUpdate_Fact(unittest.TestCase):
self._plugin._task.args = {"before": before, "after": after}
result = self._plugin.run(task_vars=self._task_vars)
self.assertTrue(result["changed"])
mlines = [
line for line in result["diff_lines"] if re.match(r"^-\s+3$", line)
]
mlines = [line for line in result["diff_lines"] if re.match(r"^-\s+3$", line)]
self.assertEqual(1, len(mlines))
mlines = [
line
for line in result["diff_lines"]
if re.match(r"^\+\s+4$", line)
]
mlines = [line for line in result["diff_lines"] if re.match(r"^\+\s+4$", line)]
self.assertEqual(1, len(mlines))
def test_invalid_diff_engine_not_collection(self):

View File

@@ -5,29 +5,30 @@
from __future__ import absolute_import, division, print_function
__metaclass__ = type
import copy
import unittest
from jinja2 import Template, TemplateSyntaxError
from ansible.playbook.task import Task
from ansible.template import Templar
from jinja2 import Template, TemplateSyntaxError
from ansible_collections.ansible.utils.plugins.action.update_fact import ActionModule
from ansible_collections.ansible.utils.plugins.action.update_fact import (
ActionModule,
)
try:
from unittest.mock import MagicMock # pylint:disable=syntax-error
except ImportError:
from mock import MagicMock
from mock import MagicMock # pyright: ignore[reportMissingModuleSource]
VALID_DATA = {
"a": {
"b": {"4.4": [{"1": {5: {"foo": 123}}}], 5.5: "float5.5"},
"127.0.0.1": "localhost",
}
},
}
VALID_TESTS = [
@@ -81,7 +82,10 @@ INVALID_JINJA = [
class TestUpdate_Fact(unittest.TestCase):
def setUp(self):
task = MagicMock(Task)
# Ansible > 2.13 looks for check_mode in task
task.check_mode = False
play_context = MagicMock()
# Ansible <= 2.13 looks for check_mode in play_context
play_context.check_mode = False
connection = MagicMock()
fake_loader = {}
@@ -101,18 +105,14 @@ class TestUpdate_Fact(unittest.TestCase):
self._plugin._task.args = {"a": 10}
with self.assertRaises(Exception) as error:
self._plugin.run(task_vars=None)
self.assertIn(
"missing required arguments: updates", str(error.exception)
)
self.assertIn("missing required arguments: updates", str(error.exception))
def test_argspec_none(self):
"""Check passing a dict"""
self._plugin._task.args = {}
with self.assertRaises(Exception) as error:
self._plugin.run(task_vars=None)
self.assertIn(
"missing required arguments: updates", str(error.exception)
)
self.assertIn("missing required arguments: updates", str(error.exception))
def test_valid_jinja(self):
for test in VALID_TESTS:
@@ -137,9 +137,7 @@ class TestUpdate_Fact(unittest.TestCase):
self._plugin._task.args = {"updates": [{"path": "a.b.c", "value": 5}]}
with self.assertRaises(Exception) as error:
self._plugin.run(task_vars={"vars": {}})
self.assertIn(
"'a' was not found in the current facts.", str(error.exception)
)
self.assertIn("'a' was not found in the current facts.", str(error.exception))
def test_run_simple(self):
"""Confirm a valid argspec passes"""
@@ -153,9 +151,7 @@ class TestUpdate_Fact(unittest.TestCase):
def test_run_multiple(self):
"""Confirm multiple paths passes"""
task_vars = {
"vars": {"a": {"b1": [1, 2, 3], "b2": {"c": "123", "d": False}}}
}
task_vars = {"vars": {"a": {"b1": [1, 2, 3], "b2": {"c": "123", "d": False}}}}
expected = {"a": {"b1": [1, 2, 3, 4], "b2": {"c": 456, "d": True}}}
expected.update({"changed": True})
self._plugin._task.args = {
@@ -163,7 +159,7 @@ class TestUpdate_Fact(unittest.TestCase):
{"path": "a.b1.3", "value": 4},
{"path": "a.b2.c", "value": 456},
{"path": "a.b2.d", "value": True},
]
],
}
result = self._plugin.run(task_vars=task_vars)
self.assertEqual(result, expected)
@@ -194,9 +190,7 @@ class TestUpdate_Fact(unittest.TestCase):
expected = copy.deepcopy(task_vars["vars"])
expected["a"]["b"].append(4)
expected.update({"changed": True})
self._plugin._task.args = {
"updates": [{"path": "a['b'][3]", "value": 4}]
}
self._plugin._task.args = {"updates": [{"path": "a['b'][3]", "value": 4}]}
result = self._plugin.run(task_vars=task_vars)
self.assertEqual(result, expected)
@@ -206,9 +200,7 @@ class TestUpdate_Fact(unittest.TestCase):
expected = copy.deepcopy(task_vars["vars"])
expected["a"]["b"].append(4)
expected.update({"changed": True})
self._plugin._task.args = {
"updates": [{"path": 'a["b"][3]', "value": 4}]
}
self._plugin._task.args = {"updates": [{"path": 'a["b"][3]', "value": 4}]}
result = self._plugin.run(task_vars=task_vars)
self.assertEqual(result, expected)
@@ -228,9 +220,7 @@ class TestUpdate_Fact(unittest.TestCase):
expected = copy.deepcopy(task_vars["vars"])
expected["a"]["0"][0] = 0
expected.update({"changed": True})
self._plugin._task.args = {
"updates": [{"path": 'a["0"].0', "value": 0}]
}
self._plugin._task.args = {"updates": [{"path": 'a["0"].0', "value": 0}]}
result = self._plugin.run(task_vars=task_vars)
self.assertEqual(result, expected)
@@ -243,9 +233,7 @@ class TestUpdate_Fact(unittest.TestCase):
def test_run_invalid_path_bracket_after_dot(self):
"""Invalid path format"""
self._plugin._task.args = {
"updates": [{"path": "a.['b']", "value": 0}]
}
self._plugin._task.args = {"updates": [{"path": "a.['b']", "value": 0}]}
with self.assertRaises(Exception) as error:
self._plugin.run(task_vars={"vars": {}})
self.assertIn("malformed", str(error.exception))
@@ -273,9 +261,7 @@ class TestUpdate_Fact(unittest.TestCase):
expected = copy.deepcopy(task_vars["vars"])
expected["a"]["b"] = [1, 2, 3]
expected.update({"changed": False})
self._plugin._task.args = {
"updates": [{"path": "a.b", "value": [1, 2, 3]}]
}
self._plugin._task.args = {"updates": [{"path": "a.b", "value": [1, 2, 3]}]}
result = self._plugin.run(task_vars=task_vars)
self.assertEqual(result, expected)
@@ -290,14 +276,10 @@ class TestUpdate_Fact(unittest.TestCase):
def test_run_list_not_int(self):
"""Confirm error when key not found"""
task_vars = {"vars": {"a": {"b": [1]}}}
self._plugin._task.args = {
"updates": [{"path": "a.b['0']", "value": 2}]
}
self._plugin._task.args = {"updates": [{"path": "a.b['0']", "value": 2}]}
with self.assertRaises(Exception) as error:
self._plugin.run(task_vars=task_vars)
self.assertIn(
"index provided was not an integer", str(error.exception)
)
self.assertIn("index provided was not an integer", str(error.exception))
def test_run_list_not_long(self):
"""List not long enough"""
@@ -305,9 +287,7 @@ class TestUpdate_Fact(unittest.TestCase):
self._plugin._task.args = {"updates": [{"path": "a.b.2", "value": 2}]}
with self.assertRaises(Exception) as error:
self._plugin.run(task_vars=task_vars)
self.assertIn(
"not long enough for item #2 to be set", str(error.exception)
)
self.assertIn("not long enough for item #2 to be set", str(error.exception))
def test_not_mutable_sequence_or_mapping(self):
"""Confirm graceful fail when immutable object
@@ -346,9 +326,7 @@ class TestUpdate_Fact(unittest.TestCase):
self._plugin._task.args = {"updates": [{"path": "123", "value": 1}]}
with self.assertRaises(Exception) as error:
self._plugin.run(task_vars=task_vars)
self.assertIn(
"'123' was not found in the current facts", str(error.exception)
)
self.assertIn("'123' was not found in the current facts", str(error.exception))
def test_run_not_dotted_success_same(self):
"""Test with a not dotted key, no change"""
@@ -365,8 +343,6 @@ class TestUpdate_Fact(unittest.TestCase):
expected = copy.deepcopy(task_vars["vars"])
expected["a"]["True"] = 1
expected.update({"changed": True})
self._plugin._task.args = {
"updates": [{"path": "a['True']", "value": 1}]
}
self._plugin._task.args = {"updates": [{"path": "a['True']", "value": 1}]}
result = self._plugin.run(task_vars=task_vars)
self.assertEqual(result, expected)

View File

@@ -5,21 +5,22 @@
from __future__ import absolute_import, division, print_function
__metaclass__ = type
import unittest
from ansible.errors import AnsibleActionFail
from ansible.playbook.task import Task
from ansible.template import Templar
from ansible.errors import AnsibleActionFail
from ansible_collections.ansible.utils.plugins.action.validate import (
ActionModule,
)
from ansible_collections.ansible.utils.plugins.action.validate import ActionModule
try:
from unittest.mock import MagicMock # pylint:disable=syntax-error
except ImportError:
from mock import MagicMock
from mock import MagicMock # pyright: ignore[reportMissingModuleSource]
DATA = {
@@ -61,21 +62,15 @@ CRITERIA_CRC_ERROR_CHECK = {
"^.*": {
"type": "object",
"properties": {
"counters": {
"properties": {
"in_crc_errors": {"type": "number", "maximum": 0}
}
}
"counters": {"properties": {"in_crc_errors": {"type": "number", "maximum": 0}}},
},
}
},
},
}
CRITERIA_ENABLED_CHECK = {
"type": "object",
"patternProperties": {
"^.*": {"type": "object", "properties": {"enabled": {"enum": [True]}}}
},
"patternProperties": {"^.*": {"type": "object", "properties": {"enabled": {"enum": [True]}}}},
}
CRITERIA_OPER_STATUS_UP_CHECK = {
@@ -84,7 +79,7 @@ CRITERIA_OPER_STATUS_UP_CHECK = {
"^.*": {
"type": "object",
"properties": {"oper_status": {"type": "string", "pattern": "up"}},
}
},
},
}
@@ -96,15 +91,11 @@ CRITERIA_IN_RATE_CHECK = {
"properties": {
"counters": {
"properties": {
"rate": {
"properties": {
"in_rate": {"type": "number", "maximum": 0}
}
}
}
}
"rate": {"properties": {"in_rate": {"type": "number", "maximum": 0}}},
},
},
},
}
},
},
}
@@ -182,9 +173,7 @@ class TestValidate(unittest.TestCase):
with self.assertRaises(AnsibleActionFail) as error:
self._plugin.run(task_vars=None)
self.assertIn(
"'criteria' option value is invalid", str(error.exception)
)
self.assertIn("'criteria' option value is invalid", str(error.exception))
def test_invalid_validate_plugin_config_options(self):
"""Check passing invalid validate plugin options"""
@@ -195,11 +184,9 @@ class TestValidate(unittest.TestCase):
"criteria": CRITERIA_IN_RATE_CHECK,
}
result = self._plugin.run(
task_vars={"ansible_validate_jsonschema_draft": "draft0"}
)
result = self._plugin.run(task_vars={"ansible_validate_jsonschema_draft": "draft0"})
self.assertIn(
"value of draft must be one of: draft3, draft4, draft6, draft7, got: draft0",
"value of draft must be one of: draft3, draft4, draft6, draft7, 2019-09, 2020-12, got: draft0",
result["msg"],
)
@@ -212,9 +199,7 @@ class TestValidate(unittest.TestCase):
"criteria": CRITERIA_IN_RATE_CHECK,
}
result = self._plugin.run(
task_vars={"ansible_validate_jsonschema_draft": "draft3"}
)
result = self._plugin.run(task_vars={"ansible_validate_jsonschema_draft": "draft3"})
self.assertIn("All checks passed", result["msg"])
def test_validate_plugin_config_options_with_draft4(self):
@@ -226,9 +211,7 @@ class TestValidate(unittest.TestCase):
"criteria": CRITERIA_IN_RATE_CHECK,
}
result = self._plugin.run(
task_vars={"ansible_validate_jsonschema_draft": "draft4"}
)
result = self._plugin.run(task_vars={"ansible_validate_jsonschema_draft": "draft4"})
self.assertIn("All checks passed", result["msg"])
def test_validate_plugin_config_options_with_draft6(self):
@@ -240,9 +223,7 @@ class TestValidate(unittest.TestCase):
"criteria": CRITERIA_IN_RATE_CHECK,
}
result = self._plugin.run(
task_vars={"ansible_validate_jsonschema_draft": "draft6"}
)
result = self._plugin.run(task_vars={"ansible_validate_jsonschema_draft": "draft6"})
self.assertIn("All checks passed", result["msg"])
def test_invalid_data(self):
@@ -263,9 +244,7 @@ class TestValidate(unittest.TestCase):
"patternProperties.^.*.properties.counters.properties.in_crc_errors.maximum",
result["msg"],
)
self.assertIn(
"patternProperties.^.*.properties.enabled.enum", result["msg"]
)
self.assertIn("patternProperties.^.*.properties.enabled.enum", result["msg"])
self.assertIn(
"'patternProperties.^.*.properties.oper_status.pattern",
result["msg"],
@@ -306,3 +285,15 @@ class TestValidate(unittest.TestCase):
result = self._plugin.run(task_vars=None)
self.assertIn("Validation errors were found", result["msg"])
def test_support_for_disabled_format_with_invalid_data(self):
"""Check passing valid data as per criteria"""
self._plugin._task.args = {
"engine": "ansible.utils.jsonschema",
"data": IN_VALID_DATA,
"criteria": CRITERIA_FORMAT_SUPPORT_CHECK,
}
result = self._plugin.run(task_vars=dict(ansible_validate_jsonschema_check_format=False))
self.assertIn("All checks passed", result["msg"])