summaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/compat/mock.py5
-rw-r--r--tests/unit/mock/loader.py2
-rw-r--r--tests/unit/mock/path.py6
-rw-r--r--tests/unit/mock/procenv.py9
-rw-r--r--tests/unit/mock/vault_helper.py5
-rw-r--r--tests/unit/mock/yaml_helper.py34
-rw-r--r--tests/unit/modules/conftest.py20
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_banner.py11
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_bgp_address_family.py153
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_bgp_global.py27
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_command.py23
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_config.py32
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_facts.py12
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_firewall_global.py15
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_firewall_interfaces.py79
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_firewall_rules.py35
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_hostname.py47
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_interfaces.py17
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_logging_global.py32
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_ntp_global.py35
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_ospf_interfaces.py39
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_ospfv2.py27
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_ospfv3.py23
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_ping.py7
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_prefix_lists.py12
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_route_maps.py15
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_snmp_server.py111
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_static_routes.py47
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_system.py11
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_user.py23
-rw-r--r--tests/unit/modules/network/vyos/vyos_module.py7
-rw-r--r--tests/unit/modules/utils.py5
32 files changed, 262 insertions, 664 deletions
diff --git a/tests/unit/compat/mock.py b/tests/unit/compat/mock.py
index b7df24f..4bef4c2 100644
--- a/tests/unit/compat/mock.py
+++ b/tests/unit/compat/mock.py
@@ -24,6 +24,7 @@ __metaclass__ = type
Compat module for Python3.x's unittest.mock module
"""
import sys
+
import _io
# Python 2.7
@@ -102,9 +103,7 @@ if sys.version_info >= (3,) and sys.version_info < (3, 4, 4):
global file_spec
if file_spec is None:
- file_spec = list(
- set(dir(_io.TextIOWrapper)).union(set(dir(_io.BytesIO)))
- )
+ file_spec = list(set(dir(_io.TextIOWrapper)).union(set(dir(_io.BytesIO))))
if mock is None:
mock = MagicMock(name="open", spec=open)
diff --git a/tests/unit/mock/loader.py b/tests/unit/mock/loader.py
index aea5df5..258dccd 100644
--- a/tests/unit/mock/loader.py
+++ b/tests/unit/mock/loader.py
@@ -23,8 +23,8 @@ __metaclass__ = type
import os
from ansible.errors import AnsibleParserError
-from ansible.parsing.dataloader import DataLoader
from ansible.module_utils._text import to_bytes, to_text
+from ansible.parsing.dataloader import DataLoader
class DictDataLoader(DataLoader):
diff --git a/tests/unit/mock/path.py b/tests/unit/mock/path.py
index 74b02be..3962f24 100644
--- a/tests/unit/mock/path.py
+++ b/tests/unit/mock/path.py
@@ -1,10 +1,8 @@
from __future__ import absolute_import, division, print_function
__metaclass__ = type
-from ansible_collections.vyos.vyos.tests.unit.compat.mock import MagicMock
from ansible.utils.path import unfrackpath
+from ansible_collections.vyos.vyos.tests.unit.compat.mock import MagicMock
-mock_unfrackpath_noop = MagicMock(
- spec_set=unfrackpath, side_effect=lambda x, *args, **kwargs: x
-)
+mock_unfrackpath_noop = MagicMock(spec_set=unfrackpath, side_effect=lambda x, *args, **kwargs: x)
diff --git a/tests/unit/mock/procenv.py b/tests/unit/mock/procenv.py
index 1587949..06987e3 100644
--- a/tests/unit/mock/procenv.py
+++ b/tests/unit/mock/procenv.py
@@ -21,14 +21,15 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
-import sys
import json
-
+import sys
from contextlib import contextmanager
from io import BytesIO, StringIO
-from ansible_collections.vyos.vyos.tests.unit.compat import unittest
-from ansible.module_utils.six import PY3
+
from ansible.module_utils._text import to_bytes
+from ansible.module_utils.six import PY3
+
+from ansible_collections.vyos.vyos.tests.unit.compat import unittest
@contextmanager
diff --git a/tests/unit/mock/vault_helper.py b/tests/unit/mock/vault_helper.py
index b34ae13..4c6c890 100644
--- a/tests/unit/mock/vault_helper.py
+++ b/tests/unit/mock/vault_helper.py
@@ -17,7 +17,6 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
from ansible.module_utils._text import to_bytes
-
from ansible.parsing.vault import VaultSecret
@@ -37,6 +36,4 @@ class TextVaultSecret(VaultSecret):
@property
def bytes(self):
"""The text encoded with encoding, unless we specifically set _bytes."""
- return self._bytes or to_bytes(
- self.text, encoding=self.encoding, errors=self.errors
- )
+ return self._bytes or to_bytes(self.text, encoding=self.encoding, errors=self.errors)
diff --git a/tests/unit/mock/yaml_helper.py b/tests/unit/mock/yaml_helper.py
index 5df30aa..540055d 100644
--- a/tests/unit/mock/yaml_helper.py
+++ b/tests/unit/mock/yaml_helper.py
@@ -2,11 +2,11 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
import io
-import yaml
+import yaml
from ansible.module_utils.six import PY3
-from ansible.parsing.yaml.loader import AnsibleLoader
from ansible.parsing.yaml.dumper import AnsibleDumper
+from ansible.parsing.yaml.loader import AnsibleLoader
class YamlTestUtils(object):
@@ -44,9 +44,7 @@ class YamlTestUtils(object):
obj_2 = loader.get_data()
# dump the gen 2 objects directory to strings
- string_from_object_dump_2 = self._dump_string(
- obj_2, dumper=AnsibleDumper
- )
+ string_from_object_dump_2 = self._dump_string(obj_2, dumper=AnsibleDumper)
# The gen 1 and gen 2 yaml strings
self.assertEqual(string_from_object_dump, string_from_object_dump_2)
@@ -58,9 +56,7 @@ class YamlTestUtils(object):
loader_3 = self._loader(stream_3)
obj_3 = loader_3.get_data()
- string_from_object_dump_3 = self._dump_string(
- obj_3, dumper=AnsibleDumper
- )
+ string_from_object_dump_3 = self._dump_string(obj_3, dumper=AnsibleDumper)
self.assertEqual(obj, obj_3)
# should be transitive, but...
@@ -92,12 +88,8 @@ class YamlTestUtils(object):
stream_obj_from_string = io.StringIO()
if PY3:
- yaml.dump(
- obj_from_stream, stream_obj_from_stream, Dumper=AnsibleDumper
- )
- yaml.dump(
- obj_from_stream, stream_obj_from_string, Dumper=AnsibleDumper
- )
+ yaml.dump(obj_from_stream, stream_obj_from_stream, Dumper=AnsibleDumper)
+ yaml.dump(obj_from_stream, stream_obj_from_string, Dumper=AnsibleDumper)
else:
yaml.dump(
obj_from_stream,
@@ -119,12 +111,8 @@ class YamlTestUtils(object):
stream_obj_from_string.seek(0)
if PY3:
- yaml_string_obj_from_stream = yaml.dump(
- obj_from_stream, Dumper=AnsibleDumper
- )
- yaml_string_obj_from_string = yaml.dump(
- obj_from_string, Dumper=AnsibleDumper
- )
+ yaml_string_obj_from_stream = yaml.dump(obj_from_stream, Dumper=AnsibleDumper)
+ yaml_string_obj_from_string = yaml.dump(obj_from_string, Dumper=AnsibleDumper)
else:
yaml_string_obj_from_stream = yaml.dump(
obj_from_stream, Dumper=AnsibleDumper, encoding=None
@@ -134,11 +122,7 @@ class YamlTestUtils(object):
)
assert yaml_string == yaml_string_obj_from_stream
- assert (
- yaml_string
- == yaml_string_obj_from_stream
- == yaml_string_obj_from_string
- )
+ assert yaml_string == yaml_string_obj_from_stream == yaml_string_obj_from_string
assert (
yaml_string
== yaml_string_obj_from_stream
diff --git a/tests/unit/modules/conftest.py b/tests/unit/modules/conftest.py
index e19a1e0..013d198 100644
--- a/tests/unit/modules/conftest.py
+++ b/tests/unit/modules/conftest.py
@@ -7,10 +7,9 @@ __metaclass__ = type
import json
import pytest
-
-from ansible.module_utils.six import string_types
from ansible.module_utils._text import to_bytes
from ansible.module_utils.common._collections_compat import MutableMapping
+from ansible.module_utils.six import string_types
@pytest.fixture
@@ -21,20 +20,11 @@ def patch_ansible_module(request, mocker):
if "ANSIBLE_MODULE_ARGS" not in request.param:
request.param = {"ANSIBLE_MODULE_ARGS": request.param}
if "_ansible_remote_tmp" not in request.param["ANSIBLE_MODULE_ARGS"]:
- request.param["ANSIBLE_MODULE_ARGS"][
- "_ansible_remote_tmp"
- ] = "/tmp"
- if (
- "_ansible_keep_remote_files"
- not in request.param["ANSIBLE_MODULE_ARGS"]
- ):
- request.param["ANSIBLE_MODULE_ARGS"][
- "_ansible_keep_remote_files"
- ] = False
+ request.param["ANSIBLE_MODULE_ARGS"]["_ansible_remote_tmp"] = "/tmp"
+ if "_ansible_keep_remote_files" not in request.param["ANSIBLE_MODULE_ARGS"]:
+ request.param["ANSIBLE_MODULE_ARGS"]["_ansible_keep_remote_files"] = False
args = json.dumps(request.param)
else:
- raise Exception(
- "Malformed data to the patch_ansible_module pytest fixture"
- )
+ raise Exception("Malformed data to the patch_ansible_module pytest fixture")
mocker.patch("ansible.module_utils.basic._ANSIBLE_ARGS", to_bytes(args))
diff --git a/tests/unit/modules/network/vyos/test_vyos_banner.py b/tests/unit/modules/network/vyos/test_vyos_banner.py
index 4281cba..08d4424 100644
--- a/tests/unit/modules/network/vyos/test_vyos_banner.py
+++ b/tests/unit/modules/network/vyos/test_vyos_banner.py
@@ -18,11 +18,10 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
-from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
from ansible_collections.vyos.vyos.plugins.modules import vyos_banner
-from ansible_collections.vyos.vyos.tests.unit.modules.utils import (
- set_module_args,
-)
+from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
+from ansible_collections.vyos.vyos.tests.unit.modules.utils import set_module_args
+
from .vyos_module import TestVyosModule
@@ -53,9 +52,7 @@ class TestVyosBannerModule(TestVyosModule):
def test_vyos_banner_create(self):
set_module_args(dict(banner="pre-login", text="test\nbanner\nstring"))
- commands = [
- "set system login banner pre-login 'test\\nbanner\\nstring'"
- ]
+ commands = ["set system login banner pre-login 'test\\nbanner\\nstring'"]
self.execute_module(changed=True, commands=commands)
def test_vyos_banner_remove(self):
diff --git a/tests/unit/modules/network/vyos/test_vyos_bgp_address_family.py b/tests/unit/modules/network/vyos/test_vyos_bgp_address_family.py
index db39466..a9f0ef1 100644
--- a/tests/unit/modules/network/vyos/test_vyos_bgp_address_family.py
+++ b/tests/unit/modules/network/vyos/test_vyos_bgp_address_family.py
@@ -20,13 +20,10 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
+from ansible_collections.vyos.vyos.plugins.modules import vyos_bgp_address_family
from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
-from ansible_collections.vyos.vyos.plugins.modules import (
- vyos_bgp_address_family,
-)
-from ansible_collections.vyos.vyos.tests.unit.modules.utils import (
- set_module_args,
-)
+from ansible_collections.vyos.vyos.tests.unit.modules.utils import set_module_args
+
from .vyos_module import TestVyosModule, load_fixture
@@ -39,9 +36,7 @@ class TestVyosBgpafModule(TestVyosModule):
self.mock_get_resource_connection_config = patch(
"ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection"
)
- self.get_resource_connection_config = (
- self.mock_get_resource_connection_config.start()
- )
+ self.get_resource_connection_config = self.mock_get_resource_connection_config.start()
self.mock_execute_show_command = patch(
"ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts."
@@ -72,13 +67,9 @@ class TestVyosBgpafModule(TestVyosModule):
address_family=[
dict(
afi="ipv4",
- aggregate_address=[
- dict(prefix="192.0.2.0/24", as_set=True)
- ],
+ aggregate_address=[dict(prefix="192.0.2.0/24", as_set=True)],
networks=[
- dict(
- prefix="192.1.13.0/24", route_map="map01"
- ),
+ dict(prefix="192.1.13.0/24", route_map="map01"),
dict(prefix="192.2.13.0/24", backdoor=True),
],
),
@@ -93,11 +84,7 @@ class TestVyosBgpafModule(TestVyosModule):
address_family=[
dict(
afi="ipv4",
- route_map=[
- dict(
- action="export", route_map="map01"
- )
- ],
+ route_map=[dict(action="export", route_map="map01")],
soft_reconfiguration=True,
),
],
@@ -125,13 +112,9 @@ class TestVyosBgpafModule(TestVyosModule):
address_family=[
dict(
afi="ipv4",
- aggregate_address=[
- dict(prefix="192.0.2.0/24", summary_only=True)
- ],
+ aggregate_address=[dict(prefix="192.0.2.0/24", summary_only=True)],
networks=[
- dict(
- prefix="192.1.13.0/24", route_map="map01"
- ),
+ dict(prefix="192.1.13.0/24", route_map="map01"),
],
),
dict(
@@ -145,9 +128,7 @@ class TestVyosBgpafModule(TestVyosModule):
address_family=[
dict(
afi="ipv6",
- distribute_list=[
- dict(action="export", acl=10)
- ],
+ distribute_list=[dict(action="export", acl=10)],
route_server_client=True,
),
],
@@ -158,9 +139,7 @@ class TestVyosBgpafModule(TestVyosModule):
dict(
afi="ipv4",
filter_list=[
- dict(
- action="export", path_list="list01"
- ),
+ dict(action="export", path_list="list01"),
],
capability=dict(orf="send"),
)
@@ -189,13 +168,9 @@ class TestVyosBgpafModule(TestVyosModule):
address_family=[
dict(
afi="ipv4",
- aggregate_address=[
- dict(prefix="192.0.2.0/24", as_set=True)
- ],
+ aggregate_address=[dict(prefix="192.0.2.0/24", as_set=True)],
networks=[
- dict(
- prefix="192.1.13.0/24", route_map="map01"
- ),
+ dict(prefix="192.1.13.0/24", route_map="map01"),
dict(prefix="192.2.13.0/24", backdoor=True),
],
),
@@ -210,11 +185,7 @@ class TestVyosBgpafModule(TestVyosModule):
address_family=[
dict(
afi="ipv4",
- route_map=[
- dict(
- action="export", route_map="map01"
- )
- ],
+ route_map=[dict(action="export", route_map="map01")],
soft_reconfiguration=True,
),
],
@@ -243,13 +214,9 @@ class TestVyosBgpafModule(TestVyosModule):
address_family=[
dict(
afi="ipv4",
- aggregate_address=[
- dict(prefix="192.0.2.0/24", summary_only=True)
- ],
+ aggregate_address=[dict(prefix="192.0.2.0/24", summary_only=True)],
networks=[
- dict(
- prefix="192.1.13.0/24", route_map="map01"
- ),
+ dict(prefix="192.1.13.0/24", route_map="map01"),
],
),
dict(
@@ -263,17 +230,11 @@ class TestVyosBgpafModule(TestVyosModule):
address_family=[
dict(
afi="ipv4",
- route_map=[
- dict(
- action="import", route_map="map01"
- )
- ],
+ route_map=[dict(action="import", route_map="map01")],
),
dict(
afi="ipv6",
- distribute_list=[
- dict(action="export", acl=10)
- ],
+ distribute_list=[dict(action="export", acl=10)],
route_server_client=True,
),
],
@@ -283,11 +244,7 @@ class TestVyosBgpafModule(TestVyosModule):
address_family=[
dict(
afi="ipv4",
- route_map=[
- dict(
- action="export", route_map="map01"
- )
- ],
+ route_map=[dict(action="export", route_map="map01")],
),
],
),
@@ -297,9 +254,7 @@ class TestVyosBgpafModule(TestVyosModule):
dict(
afi="ipv4",
filter_list=[
- dict(
- action="export", path_list="list01"
- ),
+ dict(action="export", path_list="list01"),
],
capability=dict(orf="send"),
)
@@ -333,13 +288,9 @@ class TestVyosBgpafModule(TestVyosModule):
address_family=[
dict(
afi="ipv4",
- aggregate_address=[
- dict(prefix="192.0.2.0/24", as_set=True)
- ],
+ aggregate_address=[dict(prefix="192.0.2.0/24", as_set=True)],
networks=[
- dict(
- prefix="192.1.13.0/24", route_map="map01"
- ),
+ dict(prefix="192.1.13.0/24", route_map="map01"),
dict(prefix="192.2.13.0/24", backdoor=True),
],
),
@@ -354,11 +305,7 @@ class TestVyosBgpafModule(TestVyosModule):
address_family=[
dict(
afi="ipv4",
- route_map=[
- dict(
- action="export", route_map="map01"
- )
- ],
+ route_map=[dict(action="export", route_map="map01")],
soft_reconfiguration=True,
),
],
@@ -388,9 +335,7 @@ class TestVyosBgpafModule(TestVyosModule):
dict(
afi="ipv4",
networks=[
- dict(
- prefix="192.1.13.0/24", route_map="map01"
- ),
+ dict(prefix="192.1.13.0/24", route_map="map01"),
],
),
dict(
@@ -404,17 +349,11 @@ class TestVyosBgpafModule(TestVyosModule):
address_family=[
dict(
afi="ipv4",
- route_map=[
- dict(
- action="import", route_map="map01"
- )
- ],
+ route_map=[dict(action="import", route_map="map01")],
),
dict(
afi="ipv6",
- distribute_list=[
- dict(action="export", acl=10)
- ],
+ distribute_list=[dict(action="export", acl=10)],
route_server_client=True,
),
],
@@ -481,9 +420,7 @@ class TestVyosBgpafModule(TestVyosModule):
dict(
afi="ipv4",
networks=[
- dict(
- prefix="192.1.13.0/24", route_map="map01"
- ),
+ dict(prefix="192.1.13.0/24", route_map="map01"),
],
),
dict(
@@ -497,17 +434,11 @@ class TestVyosBgpafModule(TestVyosModule):
address_family=[
dict(
afi="ipv4",
- route_map=[
- dict(
- action="import", route_map="map01"
- )
- ],
+ route_map=[dict(action="import", route_map="map01")],
),
dict(
afi="ipv6",
- distribute_list=[
- dict(action="export", acl=10)
- ],
+ distribute_list=[dict(action="export", acl=10)],
route_server_client=True,
),
],
@@ -517,9 +448,7 @@ class TestVyosBgpafModule(TestVyosModule):
)
)
result = self.execute_module(failed=True)
- self.assertIn(
- "Only one bgp instance is allowed per device", result["msg"]
- )
+ self.assertIn("Only one bgp instance is allowed per device", result["msg"])
def test_vyos_bgp_address_family_rendered(self):
set_module_args(
@@ -530,13 +459,9 @@ class TestVyosBgpafModule(TestVyosModule):
address_family=[
dict(
afi="ipv4",
- aggregate_address=[
- dict(prefix="192.0.2.0/24", as_set=True)
- ],
+ aggregate_address=[dict(prefix="192.0.2.0/24", as_set=True)],
networks=[
- dict(
- prefix="192.1.13.0/24", route_map="map01"
- ),
+ dict(prefix="192.1.13.0/24", route_map="map01"),
dict(prefix="192.2.13.0/24", backdoor=True),
],
),
@@ -551,11 +476,7 @@ class TestVyosBgpafModule(TestVyosModule):
address_family=[
dict(
afi="ipv4",
- route_map=[
- dict(
- action="export", route_map="map01"
- )
- ],
+ route_map=[dict(action="export", route_map="map01")],
soft_reconfiguration=True,
),
],
@@ -613,9 +534,7 @@ class TestVyosBgpafModule(TestVyosModule):
{"prefix": "192.1.13.0/24", "route_map": "map01"},
{"prefix": "192.2.13.0/24", "backdoor": True},
],
- "aggregate_address": [
- {"prefix": "192.0.2.0/24", "as_set": True}
- ],
+ "aggregate_address": [{"prefix": "192.0.2.0/24", "as_set": True}],
},
{
"afi": "ipv6",
@@ -654,9 +573,7 @@ class TestVyosBgpafModule(TestVyosModule):
{"prefix": "192.1.13.0/24", "route_map": "map01"},
{"prefix": "192.2.13.0/24", "backdoor": True},
],
- "aggregate_address": [
- {"prefix": "192.0.2.0/24", "as_set": True}
- ],
+ "aggregate_address": [{"prefix": "192.0.2.0/24", "as_set": True}],
},
{
"afi": "ipv6",
diff --git a/tests/unit/modules/network/vyos/test_vyos_bgp_global.py b/tests/unit/modules/network/vyos/test_vyos_bgp_global.py
index 465b249..23f2e6a 100644
--- a/tests/unit/modules/network/vyos/test_vyos_bgp_global.py
+++ b/tests/unit/modules/network/vyos/test_vyos_bgp_global.py
@@ -20,11 +20,10 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
-from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
from ansible_collections.vyos.vyos.plugins.modules import vyos_bgp_global
-from ansible_collections.vyos.vyos.tests.unit.modules.utils import (
- set_module_args,
-)
+from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
+from ansible_collections.vyos.vyos.tests.unit.modules.utils import set_module_args
+
from .vyos_module import TestVyosModule, load_fixture
@@ -38,23 +37,17 @@ class TestVyosBgpglobalModule(TestVyosModule):
self.mock_get_resource_connection_config = patch(
"ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection"
)
- self.get_resource_connection_config = (
- self.mock_get_resource_connection_config.start()
- )
+ self.get_resource_connection_config = self.mock_get_resource_connection_config.start()
self.mock_execute_show_command_config = patch(
"ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.config.bgp_global.bgp_global.Bgp_global._get_config"
)
- self.execute_show_command_config = (
- self.mock_execute_show_command_config.start()
- )
+ self.execute_show_command_config = self.mock_execute_show_command_config.start()
self.mock_get_resource_connection_facts = patch(
"ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection"
)
- self.get_resource_connection_facts = (
- self.mock_get_resource_connection_facts.start()
- )
+ self.get_resource_connection_facts = self.mock_get_resource_connection_facts.start()
self.mock_execute_show_command = patch(
"ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.bgp_global.bgp_global.Bgp_globalFacts.get_device_data"
@@ -318,9 +311,7 @@ class TestVyosBgpglobalModule(TestVyosModule):
)
)
result = self.execute_module(failed=True)
- self.assertIn(
- "Only one bgp instance is allowed per device", result["msg"]
- )
+ self.assertIn("Only one bgp instance is allowed per device", result["msg"])
def test_vyos_bgp_global_replaced_af(self):
set_module_args(
@@ -356,9 +347,7 @@ class TestVyosBgpglobalModule(TestVyosModule):
state="replaced",
)
)
- result = self.execute_module(
- failed=True, filename="vyos_bgp_global_af_config.cfg"
- )
+ result = self.execute_module(failed=True, filename="vyos_bgp_global_af_config.cfg")
self.assertIn(
"Use the _bgp_address_family module to delete the address_family under neighbor 5001::64, before replacing/deleting the neighbor.",
result["msg"],
diff --git a/tests/unit/modules/network/vyos/test_vyos_command.py b/tests/unit/modules/network/vyos/test_vyos_command.py
index a8a3569..7ed049b 100644
--- a/tests/unit/modules/network/vyos/test_vyos_command.py
+++ b/tests/unit/modules/network/vyos/test_vyos_command.py
@@ -20,11 +20,10 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
-from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
from ansible_collections.vyos.vyos.plugins.modules import vyos_command
-from ansible_collections.vyos.vyos.tests.unit.modules.utils import (
- set_module_args,
-)
+from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
+from ansible_collections.vyos.vyos.tests.unit.modules.utils import set_module_args
+
from .vyos_module import TestVyosModule, load_fixture
@@ -84,9 +83,7 @@ class TestVyosCommandModule(TestVyosModule):
def test_vyos_command_retries(self):
wait_for = 'result[0] contains "test string"'
- set_module_args(
- dict(commands=["show version"], wait_for=wait_for, retries=2)
- )
+ set_module_args(dict(commands=["show version"], wait_for=wait_for, retries=2))
self.execute_module(failed=True)
self.assertEqual(self.run_commands.call_count, 2)
@@ -95,9 +92,7 @@ class TestVyosCommandModule(TestVyosModule):
'result[0] contains "VyOS maintainers"',
'result[0] contains "test string"',
]
- set_module_args(
- dict(commands=["show version"], wait_for=wait_for, match="any")
- )
+ set_module_args(dict(commands=["show version"], wait_for=wait_for, match="any"))
self.execute_module()
def test_vyos_command_match_all(self):
@@ -105,9 +100,7 @@ class TestVyosCommandModule(TestVyosModule):
'result[0] contains "VyOS maintainers"',
'result[0] contains "maintainers@vyos.net"',
]
- set_module_args(
- dict(commands=["show version"], wait_for=wait_for, match="all")
- )
+ set_module_args(dict(commands=["show version"], wait_for=wait_for, match="all"))
self.execute_module()
def test_vyos_command_match_all_failure(self):
@@ -116,7 +109,5 @@ class TestVyosCommandModule(TestVyosModule):
'result[0] contains "test string"',
]
commands = ["show version", "show version"]
- set_module_args(
- dict(commands=commands, wait_for=wait_for, match="all")
- )
+ set_module_args(dict(commands=commands, wait_for=wait_for, match="all"))
self.execute_module(failed=True)
diff --git a/tests/unit/modules/network/vyos/test_vyos_config.py b/tests/unit/modules/network/vyos/test_vyos_config.py
index c282c71..def567a 100644
--- a/tests/unit/modules/network/vyos/test_vyos_config.py
+++ b/tests/unit/modules/network/vyos/test_vyos_config.py
@@ -21,15 +21,11 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
-from ansible_collections.vyos.vyos.tests.unit.compat.mock import (
- patch,
- MagicMock,
-)
-from ansible_collections.vyos.vyos.plugins.modules import vyos_config
from ansible_collections.vyos.vyos.plugins.cliconf.vyos import Cliconf
-from ansible_collections.vyos.vyos.tests.unit.modules.utils import (
- set_module_args,
-)
+from ansible_collections.vyos.vyos.plugins.modules import vyos_config
+from ansible_collections.vyos.vyos.tests.unit.compat.mock import MagicMock, patch
+from ansible_collections.vyos.vyos.tests.unit.modules.utils import set_module_args
+
from .vyos_module import TestVyosModule, load_fixture
@@ -82,9 +78,7 @@ class TestVyosConfigModule(TestVyosModule):
def test_vyos_config_unchanged(self):
src = load_fixture("vyos_config_config.cfg")
- self.conn.get_diff = MagicMock(
- return_value=self.cliconf_obj.get_diff(src, src)
- )
+ self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff(src, src))
set_module_args(dict(src=src))
self.execute_module()
@@ -97,9 +91,7 @@ class TestVyosConfigModule(TestVyosModule):
"delete interfaces ethernet eth0 address",
]
self.conn.get_diff = MagicMock(
- return_value=self.cliconf_obj.get_diff(
- candidate, self.running_config
- )
+ return_value=self.cliconf_obj.get_diff(candidate, self.running_config)
)
self.execute_module(changed=True, commands=commands)
@@ -124,9 +116,7 @@ class TestVyosConfigModule(TestVyosModule):
set_module_args(dict(lines=commands))
candidate = "\n".join(commands)
self.conn.get_diff = MagicMock(
- return_value=self.cliconf_obj.get_diff(
- candidate, self.running_config
- )
+ return_value=self.cliconf_obj.get_diff(candidate, self.running_config)
)
self.execute_module(changed=True, commands=commands)
@@ -135,9 +125,7 @@ class TestVyosConfigModule(TestVyosModule):
new_config = ["set system host-name router"]
set_module_args(dict(lines=new_config, config=config))
candidate = "\n".join(new_config)
- self.conn.get_diff = MagicMock(
- return_value=self.cliconf_obj.get_diff(candidate, config)
- )
+ self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff(candidate, config))
self.execute_module(changed=True, commands=new_config)
def test_vyos_config_match_none(self):
@@ -148,8 +136,6 @@ class TestVyosConfigModule(TestVyosModule):
set_module_args(dict(lines=lines, match="none"))
candidate = "\n".join(lines)
self.conn.get_diff = MagicMock(
- return_value=self.cliconf_obj.get_diff(
- candidate, None, diff_match="none"
- )
+ return_value=self.cliconf_obj.get_diff(candidate, None, diff_match="none")
)
self.execute_module(changed=True, commands=lines, sort=False)
diff --git a/tests/unit/modules/network/vyos/test_vyos_facts.py b/tests/unit/modules/network/vyos/test_vyos_facts.py
index c0ef686..727f69b 100644
--- a/tests/unit/modules/network/vyos/test_vyos_facts.py
+++ b/tests/unit/modules/network/vyos/test_vyos_facts.py
@@ -19,11 +19,11 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
import json
-from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
+
from ansible_collections.vyos.vyos.plugins.modules import vyos_facts
-from ansible_collections.vyos.vyos.tests.unit.modules.utils import (
- set_module_args,
-)
+from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
+from ansible_collections.vyos.vyos.tests.unit.modules.utils import set_module_args
+
from .vyos_module import TestVyosModule, load_fixture
@@ -40,9 +40,7 @@ class TestVyosFactsModule(TestVyosModule):
self.mock_get_resource_connection = patch(
"ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection"
)
- self.get_resource_connection = (
- self.mock_get_resource_connection.start()
- )
+ self.get_resource_connection = self.mock_get_resource_connection.start()
self.mock_get_capabilities = patch(
"ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.legacy.base.get_capabilities"
diff --git a/tests/unit/modules/network/vyos/test_vyos_firewall_global.py b/tests/unit/modules/network/vyos/test_vyos_firewall_global.py
index c691f09..367da22 100644
--- a/tests/unit/modules/network/vyos/test_vyos_firewall_global.py
+++ b/tests/unit/modules/network/vyos/test_vyos_firewall_global.py
@@ -20,11 +20,10 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
-from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
from ansible_collections.vyos.vyos.plugins.modules import vyos_firewall_global
-from ansible_collections.vyos.vyos.tests.unit.modules.utils import (
- set_module_args,
-)
+from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
+from ansible_collections.vyos.vyos.tests.unit.modules.utils import set_module_args
+
from .vyos_module import TestVyosModule, load_fixture
@@ -47,16 +46,12 @@ class TestVyosFirewallRulesModule(TestVyosModule):
self.mock_get_resource_connection_config = patch(
"ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection"
)
- self.get_resource_connection_config = (
- self.mock_get_resource_connection_config.start()
- )
+ self.get_resource_connection_config = self.mock_get_resource_connection_config.start()
self.mock_get_resource_connection_facts = patch(
"ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection"
)
- self.get_resource_connection_facts = (
- self.mock_get_resource_connection_facts.start()
- )
+ self.get_resource_connection_facts = self.mock_get_resource_connection_facts.start()
self.mock_execute_show_command = patch(
"ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.firewall_global.firewall_global.Firewall_globalFacts.get_device_data"
diff --git a/tests/unit/modules/network/vyos/test_vyos_firewall_interfaces.py b/tests/unit/modules/network/vyos/test_vyos_firewall_interfaces.py
index 186edaa..fe64659 100644
--- a/tests/unit/modules/network/vyos/test_vyos_firewall_interfaces.py
+++ b/tests/unit/modules/network/vyos/test_vyos_firewall_interfaces.py
@@ -20,13 +20,10 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
+from ansible_collections.vyos.vyos.plugins.modules import vyos_firewall_interfaces
from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
-from ansible_collections.vyos.vyos.plugins.modules import (
- vyos_firewall_interfaces,
-)
-from ansible_collections.vyos.vyos.tests.unit.modules.utils import (
- set_module_args,
-)
+from ansible_collections.vyos.vyos.tests.unit.modules.utils import set_module_args
+
from .vyos_module import TestVyosModule, load_fixture
@@ -49,16 +46,12 @@ class TestVyosFirewallInterfacesModule(TestVyosModule):
self.mock_get_resource_connection_config = patch(
"ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection"
)
- self.get_resource_connection_config = (
- self.mock_get_resource_connection_config.start()
- )
+ self.get_resource_connection_config = self.mock_get_resource_connection_config.start()
self.mock_get_resource_connection_facts = patch(
"ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection"
)
- self.get_resource_connection_facts = (
- self.mock_get_resource_connection_facts.start()
- )
+ self.get_resource_connection_facts = self.mock_get_resource_connection_facts.start()
self.mock_execute_show_command = patch(
"ansible_collections.vyos.vyos.plugins.module_utils.network.vyos."
@@ -97,9 +90,7 @@ class TestVyosFirewallInterfacesModule(TestVyosModule):
),
dict(
afi="ipv6",
- rules=[
- dict(name="V6-LOCAL", direction="local")
- ],
+ rules=[dict(name="V6-LOCAL", direction="local")],
),
],
),
@@ -116,9 +107,7 @@ class TestVyosFirewallInterfacesModule(TestVyosModule):
),
dict(
afi="ipv6",
- rules=[
- dict(name="V6-LOCAL", direction="local")
- ],
+ rules=[dict(name="V6-LOCAL", direction="local")],
),
],
),
@@ -155,9 +144,7 @@ class TestVyosFirewallInterfacesModule(TestVyosModule):
),
dict(
afi="ipv6",
- rules=[
- dict(name="V6-LOCAL", direction="local")
- ],
+ rules=[dict(name="V6-LOCAL", direction="local")],
),
],
),
@@ -174,9 +161,7 @@ class TestVyosFirewallInterfacesModule(TestVyosModule):
),
dict(
afi="ipv6",
- rules=[
- dict(name="V6-LOCAL", direction="local")
- ],
+ rules=[dict(name="V6-LOCAL", direction="local")],
),
],
),
@@ -207,11 +192,7 @@ class TestVyosFirewallInterfacesModule(TestVyosModule):
self.execute_module(changed=True, commands=commands)
def test_vyos_firewall_rule_set_03_deleted_per_interface(self):
- set_module_args(
- dict(
- config=[dict(name="eth0"), dict(name="eth2")], state="deleted"
- )
- )
+ set_module_args(dict(config=[dict(name="eth0"), dict(name="eth2")], state="deleted"))
commands = [
"delete interfaces ethernet eth0 firewall",
"delete interfaces ethernet eth2 firewall",
@@ -227,11 +208,7 @@ class TestVyosFirewallInterfacesModule(TestVyosModule):
self.execute_module(changed=True, commands=commands)
def test_vyos_firewall_rule_set_03_deleted(self):
- set_module_args(
- dict(
- config=[dict(name="eth0"), dict(name="eth2")], state="deleted"
- )
- )
+ set_module_args(dict(config=[dict(name="eth0"), dict(name="eth2")], state="deleted"))
commands = [
"delete interfaces ethernet eth0 firewall",
"delete interfaces ethernet eth2 firewall",
@@ -239,11 +216,7 @@ class TestVyosFirewallInterfacesModule(TestVyosModule):
self.execute_module(changed=True, commands=commands)
def test_vyos_firewall_rule_set_04_deleted_interface_idem(self):
- set_module_args(
- dict(
- config=[dict(name="eth1"), dict(name="eth3")], state="deleted"
- )
- )
+ set_module_args(dict(config=[dict(name="eth1"), dict(name="eth3")], state="deleted"))
self.execute_module(changed=False, commands=[])
def test_vyos_firewall_rule_set_02_replaced_idem(self):
@@ -263,9 +236,7 @@ class TestVyosFirewallInterfacesModule(TestVyosModule):
),
dict(
afi="ipv6",
- rules=[
- dict(name="V6-LOCAL", direction="local")
- ],
+ rules=[dict(name="V6-LOCAL", direction="local")],
),
],
),
@@ -282,9 +253,7 @@ class TestVyosFirewallInterfacesModule(TestVyosModule):
),
dict(
afi="ipv6",
- rules=[
- dict(name="V6-LOCAL", direction="local")
- ],
+ rules=[dict(name="V6-LOCAL", direction="local")],
),
],
),
@@ -307,9 +276,7 @@ class TestVyosFirewallInterfacesModule(TestVyosModule):
),
dict(
afi="ipv6",
- rules=[
- dict(name="V6-LOCAL", direction="local")
- ],
+ rules=[dict(name="V6-LOCAL", direction="local")],
),
],
),
@@ -322,9 +289,7 @@ class TestVyosFirewallInterfacesModule(TestVyosModule):
),
dict(
afi="ipv6",
- rules=[
- dict(name="V6-LOCAL", direction="local")
- ],
+ rules=[dict(name="V6-LOCAL", direction="local")],
),
],
),
@@ -337,9 +302,7 @@ class TestVyosFirewallInterfacesModule(TestVyosModule):
),
dict(
afi="ipv6",
- rules=[
- dict(name="V6-LOCAL", direction="local")
- ],
+ rules=[dict(name="V6-LOCAL", direction="local")],
),
],
),
@@ -398,9 +361,7 @@ class TestVyosFirewallInterfacesModule(TestVyosModule):
),
dict(
afi="ipv6",
- rules=[
- dict(name="V6-LOCAL", direction="local")
- ],
+ rules=[dict(name="V6-LOCAL", direction="local")],
),
],
),
@@ -417,9 +378,7 @@ class TestVyosFirewallInterfacesModule(TestVyosModule):
),
dict(
afi="ipv6",
- rules=[
- dict(name="V6-LOCAL", direction="local")
- ],
+ rules=[dict(name="V6-LOCAL", direction="local")],
),
],
),
diff --git a/tests/unit/modules/network/vyos/test_vyos_firewall_rules.py b/tests/unit/modules/network/vyos/test_vyos_firewall_rules.py
index c82ffc6..623ab1e 100644
--- a/tests/unit/modules/network/vyos/test_vyos_firewall_rules.py
+++ b/tests/unit/modules/network/vyos/test_vyos_firewall_rules.py
@@ -20,11 +20,10 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
-from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
from ansible_collections.vyos.vyos.plugins.modules import vyos_firewall_rules
-from ansible_collections.vyos.vyos.tests.unit.modules.utils import (
- set_module_args,
-)
+from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
+from ansible_collections.vyos.vyos.tests.unit.modules.utils import set_module_args
+
from .vyos_module import TestVyosModule, load_fixture
@@ -47,16 +46,12 @@ class TestVyosFirewallRulesModule(TestVyosModule):
self.mock_get_resource_connection_config = patch(
"ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection"
)
- self.get_resource_connection_config = (
- self.mock_get_resource_connection_config.start()
- )
+ self.get_resource_connection_config = self.mock_get_resource_connection_config.start()
self.mock_get_resource_connection_facts = patch(
"ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection"
)
- self.get_resource_connection_facts = (
- self.mock_get_resource_connection_facts.start()
- )
+ self.get_resource_connection_facts = self.mock_get_resource_connection_facts.start()
self.mock_execute_show_command = patch(
"ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.static_routes.static_routes.Static_routesFacts.get_device_data"
)
@@ -271,14 +266,10 @@ class TestVyosFirewallRulesModule(TestVyosModule):
mac_address="38:00:25:19:76:0c",
port=2127,
),
- destination=dict(
- address="192.0.1.0", port=2124
- ),
+ destination=dict(address="192.0.1.0", port=2124),
limit=dict(
burst=10,
- rate=dict(
- number=20, unit="second"
- ),
+ rate=dict(number=20, unit="second"),
),
recent=dict(count=10, time=20),
state=dict(
@@ -467,14 +458,10 @@ class TestVyosFirewallRulesModule(TestVyosModule):
mac_address="38:00:25:19:76:0c",
port=2127,
),
- destination=dict(
- address="2001:db8::11", port=2124
- ),
+ destination=dict(address="2001:db8::11", port=2124),
limit=dict(
burst=10,
- rate=dict(
- number=20, unit="second"
- ),
+ rate=dict(number=20, unit="second"),
),
recent=dict(count=10, time=20),
state=dict(
@@ -614,9 +601,7 @@ class TestVyosFirewallRulesModule(TestVyosModule):
dict(
number="101",
protocol="icmp",
- icmp=dict(
- type_name="port-unreachable"
- ),
+ icmp=dict(type_name="port-unreachable"),
)
],
),
diff --git a/tests/unit/modules/network/vyos/test_vyos_hostname.py b/tests/unit/modules/network/vyos/test_vyos_hostname.py
index 54377da..13d4e32 100644
--- a/tests/unit/modules/network/vyos/test_vyos_hostname.py
+++ b/tests/unit/modules/network/vyos/test_vyos_hostname.py
@@ -20,11 +20,10 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
-from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
from ansible_collections.vyos.vyos.plugins.modules import vyos_hostname
-from ansible_collections.vyos.vyos.tests.unit.modules.utils import (
- set_module_args,
-)
+from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
+from ansible_collections.vyos.vyos.tests.unit.modules.utils import set_module_args
+
from .vyos_module import TestVyosModule, load_fixture
@@ -38,16 +37,12 @@ class TestVyosHostnameModule(TestVyosModule):
self.mock_get_resource_connection_config = patch(
"ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection"
)
- self.get_resource_connection_config = (
- self.mock_get_resource_connection_config.start()
- )
+ self.get_resource_connection_config = self.mock_get_resource_connection_config.start()
self.mock_get_resource_connection_facts = patch(
"ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection"
)
- self.get_resource_connection_facts = (
- self.mock_get_resource_connection_facts.start()
- )
+ self.get_resource_connection_facts = self.mock_get_resource_connection_facts.start()
self.mock_execute_show_command = patch(
"ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.hostname.hostname.HostnameFacts.get_config"
@@ -76,43 +71,31 @@ class TestVyosHostnameModule(TestVyosModule):
self.execute_module(changed=False, commands=[])
def test_vyos_hostname_replaced_idempotent(self):
- set_module_args(
- dict(config=dict(hostname="vyos_test"), state="replaced")
- )
+ set_module_args(dict(config=dict(hostname="vyos_test"), state="replaced"))
self.execute_module(changed=False, commands=[])
def test_vyos_hostname_overridden_idempotent(self):
- set_module_args(
- dict(config=dict(hostname="vyos_test"), state="overridden")
- )
+ set_module_args(dict(config=dict(hostname="vyos_test"), state="overridden"))
self.execute_module(changed=False, commands=[])
def test_vyos_hostname_merged(self):
set_module_args(dict(config=dict(hostname="vyos")))
- self.execute_module(
- changed=True, commands=["set system host-name vyos"]
- )
+ self.execute_module(changed=True, commands=["set system host-name vyos"])
def test_vyos_hostname_replaced(self):
set_module_args(dict(config=dict(hostname="vyos"), state="replaced"))
- self.execute_module(
- changed=True, commands=["set system host-name vyos"]
- )
+ self.execute_module(changed=True, commands=["set system host-name vyos"])
def test_vyos_hostname_overridden(self):
set_module_args(dict(config=dict(hostname="vyos"), state="overridden"))
def test_vyos_hostname_deleted(self):
set_module_args(dict(state="deleted"))
- self.execute_module(
- changed=True, commands=["delete system host-name vyos_test"]
- )
+ self.execute_module(changed=True, commands=["delete system host-name vyos_test"])
def test_vyos_hostname_gathered(self):
set_module_args(dict(state="gathered"))
- result = self.execute_module(
- changed=False, filename="vyos_hostname_config.cfg"
- )
+ result = self.execute_module(changed=False, filename="vyos_hostname_config.cfg")
gathered_list = {"hostname": "vyos_test"}
self.assertEqual(sorted(gathered_list), sorted(result["gathered"]))
@@ -124,11 +107,7 @@ class TestVyosHostnameModule(TestVyosModule):
self.assertEqual(sorted(parsed_list), sorted(result["parsed"]))
def test_vyos_hostname_rendered(self):
- set_module_args(
- dict(state="rendered", config=dict(hostname="vyos_test"))
- )
+ set_module_args(dict(state="rendered", config=dict(hostname="vyos_test")))
commands = ["set system host-name vyos_test"]
result = self.execute_module(changed=False)
- self.assertEqual(
- sorted(result["rendered"]), sorted(commands), result["rendered"]
- )
+ self.assertEqual(sorted(result["rendered"]), sorted(commands), result["rendered"])
diff --git a/tests/unit/modules/network/vyos/test_vyos_interfaces.py b/tests/unit/modules/network/vyos/test_vyos_interfaces.py
index c796145..1595040 100644
--- a/tests/unit/modules/network/vyos/test_vyos_interfaces.py
+++ b/tests/unit/modules/network/vyos/test_vyos_interfaces.py
@@ -20,13 +20,10 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
+from ansible_collections.vyos.vyos.plugins.modules import vyos_interfaces
from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
-from ansible_collections.vyos.vyos.plugins.modules import (
- vyos_interfaces,
-)
-from ansible_collections.vyos.vyos.tests.unit.modules.utils import (
- set_module_args,
-)
+from ansible_collections.vyos.vyos.tests.unit.modules.utils import set_module_args
+
from .vyos_module import TestVyosModule, load_fixture
@@ -49,16 +46,12 @@ class TestVyosFirewallInterfacesModule(TestVyosModule):
self.mock_get_resource_connection_config = patch(
"ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection"
)
- self.get_resource_connection_config = (
- self.mock_get_resource_connection_config.start()
- )
+ self.get_resource_connection_config = self.mock_get_resource_connection_config.start()
self.mock_get_resource_connection_facts = patch(
"ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection"
)
- self.get_resource_connection_facts = (
- self.mock_get_resource_connection_facts.start()
- )
+ self.get_resource_connection_facts = self.mock_get_resource_connection_facts.start()
self.mock_execute_show_command = patch(
"ansible_collections.vyos.vyos.plugins.module_utils.network.vyos."
diff --git a/tests/unit/modules/network/vyos/test_vyos_logging_global.py b/tests/unit/modules/network/vyos/test_vyos_logging_global.py
index 0f72aeb..12da571 100644
--- a/tests/unit/modules/network/vyos/test_vyos_logging_global.py
+++ b/tests/unit/modules/network/vyos/test_vyos_logging_global.py
@@ -8,11 +8,11 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
from textwrap import dedent
-from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
+
from ansible_collections.vyos.vyos.plugins.modules import vyos_logging_global
-from ansible_collections.vyos.vyos.tests.unit.modules.utils import (
- set_module_args,
-)
+from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
+from ansible_collections.vyos.vyos.tests.unit.modules.utils import set_module_args
+
from .vyos_module import TestVyosModule
@@ -26,16 +26,12 @@ class TestVyosLoggingGlobalModule(TestVyosModule):
self.mock_get_resource_connection_config = patch(
"ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection"
)
- self.get_resource_connection_config = (
- self.mock_get_resource_connection_config.start()
- )
+ self.get_resource_connection_config = self.mock_get_resource_connection_config.start()
self.mock_get_resource_connection_facts = patch(
"ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection"
)
- self.get_resource_connection_facts = (
- self.mock_get_resource_connection_facts.start()
- )
+ self.get_resource_connection_facts = self.mock_get_resource_connection_facts.start()
self.mock_execute_show_command = patch(
"ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.logging_global.logging_global.Logging_globalFacts.get_logging_data"
@@ -300,9 +296,7 @@ class TestVyosLoggingGlobalModule(TestVyosModule):
)
playbook = dict(
config=dict(
- console=dict(
- facilities=[dict(facility="local7", severity="emerg")]
- ),
+ console=dict(facilities=[dict(facility="local7", severity="emerg")]),
files=[
dict(
path="abc",
@@ -353,9 +347,7 @@ class TestVyosLoggingGlobalModule(TestVyosModule):
set system syslog console facility local6
"""
)
- playbook = dict(
- config=dict(console=dict(facilities=[dict(facility="local6")]))
- )
+ playbook = dict(config=dict(console=dict(facilities=[dict(facility="local6")])))
compare_cmds = []
playbook["state"] = "replaced"
set_module_args(playbook)
@@ -372,9 +364,7 @@ class TestVyosLoggingGlobalModule(TestVyosModule):
)
playbook = dict(
config=dict(
- console=dict(
- facilities=[dict(facility="local7", severity="emerg")]
- ),
+ console=dict(facilities=[dict(facility="local7", severity="emerg")]),
files=[
dict(
path="abc",
@@ -412,9 +402,7 @@ class TestVyosLoggingGlobalModule(TestVyosModule):
],
users=[
dict(username="vyos"),
- dict(
- username="paul", facilities=[dict(facility="local7")]
- ),
+ dict(username="paul", facilities=[dict(facility="local7")]),
],
)
)
diff --git a/tests/unit/modules/network/vyos/test_vyos_ntp_global.py b/tests/unit/modules/network/vyos/test_vyos_ntp_global.py
index 1db6c9b..0a6119b 100644
--- a/tests/unit/modules/network/vyos/test_vyos_ntp_global.py
+++ b/tests/unit/modules/network/vyos/test_vyos_ntp_global.py
@@ -20,11 +20,10 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
-from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
from ansible_collections.vyos.vyos.plugins.modules import vyos_ntp_global
-from ansible_collections.vyos.vyos.tests.unit.modules.utils import (
- set_module_args,
-)
+from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
+from ansible_collections.vyos.vyos.tests.unit.modules.utils import set_module_args
+
from .vyos_module import TestVyosModule, load_fixture
@@ -38,16 +37,12 @@ class TestVyosNTPModule(TestVyosModule):
self.mock_get_resource_connection_config = patch(
"ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection"
)
- self.get_resource_connection_config = (
- self.mock_get_resource_connection_config.start()
- )
+ self.get_resource_connection_config = self.mock_get_resource_connection_config.start()
self.mock_get_resource_connection_facts = patch(
"ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection"
)
- self.get_resource_connection_facts = (
- self.mock_get_resource_connection_facts.start()
- )
+ self.get_resource_connection_facts = self.mock_get_resource_connection_facts.start()
self.mock_execute_show_command = patch(
"ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.ntp_global.ntp_global.Ntp_globalFacts.get_config"
@@ -79,9 +74,7 @@ class TestVyosNTPModule(TestVyosModule):
listen_addresses=["10.2.3.1", "10.4.3.1"],
servers=[
dict(server="server1"),
- dict(
- server="server3", options=["noselect", "dynamic"]
- ),
+ dict(server="server3", options=["noselect", "dynamic"]),
dict(server="time1.vyos.net"),
dict(server="time2.vyos.net"),
dict(server="time3.vyos.net"),
@@ -183,9 +176,7 @@ class TestVyosNTPModule(TestVyosModule):
listen_addresses=["10.2.3.1", "10.4.3.1"],
servers=[
dict(server="server1"),
- dict(
- server="server3", options=["noselect", "dynamic"]
- ),
+ dict(server="server3", options=["noselect", "dynamic"]),
dict(server="time1.vyos.net"),
dict(server="time2.vyos.net"),
dict(server="time3.vyos.net"),
@@ -204,9 +195,7 @@ class TestVyosNTPModule(TestVyosModule):
listen_addresses=["10.9.9.1"],
servers=[
dict(server="server9"),
- dict(
- server="server6", options=["noselect", "dynamic"]
- ),
+ dict(server="server6", options=["noselect", "dynamic"]),
dict(server="time1.vyos.net"),
dict(server="time2.vyos.net"),
dict(server="time3.vyos.net"),
@@ -238,9 +227,7 @@ class TestVyosNTPModule(TestVyosModule):
listen_addresses=["10.2.3.1", "10.4.3.1"],
servers=[
dict(server="server1"),
- dict(
- server="server3", options=["noselect", "dynamic"]
- ),
+ dict(server="server3", options=["noselect", "dynamic"]),
dict(server="time1.vyos.net"),
dict(server="time2.vyos.net"),
dict(server="time3.vyos.net"),
@@ -259,9 +246,7 @@ class TestVyosNTPModule(TestVyosModule):
listen_addresses=["10.7.9.1"],
servers=[
dict(server="server79"),
- dict(
- server="server46", options=["noselect", "dynamic"]
- ),
+ dict(server="server46", options=["noselect", "dynamic"]),
dict(server="time1.vyos.net"),
dict(server="time2.vyos.net"),
dict(server="time3.vyos.net"),
diff --git a/tests/unit/modules/network/vyos/test_vyos_ospf_interfaces.py b/tests/unit/modules/network/vyos/test_vyos_ospf_interfaces.py
index 20b896d..e8c3241 100644
--- a/tests/unit/modules/network/vyos/test_vyos_ospf_interfaces.py
+++ b/tests/unit/modules/network/vyos/test_vyos_ospf_interfaces.py
@@ -20,11 +20,10 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
-from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
from ansible_collections.vyos.vyos.plugins.modules import vyos_ospf_interfaces
-from ansible_collections.vyos.vyos.tests.unit.modules.utils import (
- set_module_args,
-)
+from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
+from ansible_collections.vyos.vyos.tests.unit.modules.utils import set_module_args
+
from .vyos_module import TestVyosModule, load_fixture
@@ -37,9 +36,7 @@ class TestVyosOspfInterfacesModule(TestVyosModule):
self.mock_get_resource_connection_config = patch(
"ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection"
)
- self.get_resource_connection_config = (
- self.mock_get_resource_connection_config.start()
- )
+ self.get_resource_connection_config = self.mock_get_resource_connection_config.start()
self.mock_execute_show_command = patch(
"ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.ospf_interfaces.ospf_interfaces.Ospf_interfacesFacts.get_device_data"
@@ -76,9 +73,7 @@ class TestVyosOspfInterfacesModule(TestVyosModule):
dict(
afi="ipv4",
cost=100,
- authentication=dict(
- plaintext_password="abcdefg!"
- ),
+ authentication=dict(plaintext_password="abcdefg!"),
priority=55,
),
dict(afi="ipv6", mtu_ignore=True, instance=20),
@@ -173,9 +168,7 @@ class TestVyosOspfInterfacesModule(TestVyosModule):
dict(
afi="ipv4",
cost=100,
- authentication=dict(
- plaintext_password="abcdefg!"
- ),
+ authentication=dict(plaintext_password="abcdefg!"),
priority=55,
),
],
@@ -241,9 +234,7 @@ class TestVyosOspfInterfacesModule(TestVyosModule):
dict(
afi="ipv4",
cost=100,
- authentication=dict(
- plaintext_password="abcdefg!"
- ),
+ authentication=dict(plaintext_password="abcdefg!"),
priority=55,
),
],
@@ -338,9 +329,7 @@ class TestVyosOspfInterfacesModule(TestVyosModule):
dict(
afi="ipv4",
cost=100,
- authentication=dict(
- plaintext_password="abcdefg!"
- ),
+ authentication=dict(plaintext_password="abcdefg!"),
priority=55,
),
dict(afi="ipv6", mtu_ignore=True, instance=20),
@@ -370,9 +359,7 @@ class TestVyosOspfInterfacesModule(TestVyosModule):
"set interfaces bonding bond2 ipv6 ospfv3 passive",
]
result = self.execute_module(changed=False)
- self.assertEqual(
- sorted(result["rendered"]), sorted(commands), result["rendered"]
- )
+ self.assertEqual(sorted(result["rendered"]), sorted(commands), result["rendered"])
def test_vyos_ospf_interfaces_parsed(self):
commands = [
@@ -437,14 +424,10 @@ class TestVyosOspfInterfacesModule(TestVyosModule):
def test_vyos_ospf_interfaces_gathered(self):
set_module_args(dict(state="gathered"))
- result = self.execute_module(
- changed=False, filename="vyos_ospf_interfaces_config.cfg"
- )
+ result = self.execute_module(changed=False, filename="vyos_ospf_interfaces_config.cfg")
gathered_list = [
{
- "address_family": [
- {"afi": "ipv6", "instance": "33", "mtu_ignore": True}
- ],
+ "address_family": [{"afi": "ipv6", "instance": "33", "mtu_ignore": True}],
"name": "eth0",
},
{
diff --git a/tests/unit/modules/network/vyos/test_vyos_ospfv2.py b/tests/unit/modules/network/vyos/test_vyos_ospfv2.py
index c3631d9..e036f68 100644
--- a/tests/unit/modules/network/vyos/test_vyos_ospfv2.py
+++ b/tests/unit/modules/network/vyos/test_vyos_ospfv2.py
@@ -20,11 +20,10 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
-from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
from ansible_collections.vyos.vyos.plugins.modules import vyos_ospfv2
-from ansible_collections.vyos.vyos.tests.unit.modules.utils import (
- set_module_args,
-)
+from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
+from ansible_collections.vyos.vyos.tests.unit.modules.utils import set_module_args
+
from .vyos_module import TestVyosModule, load_fixture
@@ -47,16 +46,12 @@ class TestVyosOspfv2Module(TestVyosModule):
self.mock_get_resource_connection_config = patch(
"ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection"
)
- self.get_resource_connection_config = (
- self.mock_get_resource_connection_config.start()
- )
+ self.get_resource_connection_config = self.mock_get_resource_connection_config.start()
self.mock_get_resource_connection_facts = patch(
"ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection"
)
- self.get_resource_connection_facts = (
- self.mock_get_resource_connection_facts.start()
- )
+ self.get_resource_connection_facts = self.mock_get_resource_connection_facts.start()
self.mock_execute_show_command = patch(
"ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.ospfv2.ospfv2.Ospfv2Facts.get_device_data"
@@ -271,9 +266,7 @@ class TestVyosOspfv2Module(TestVyosModule):
def test_vyos_ospfv2_gathered(self):
set_module_args(dict(state="gathered"))
- result = self.execute_module(
- changed=False, filename="vyos_ospfv2_config.cfg"
- )
+ result = self.execute_module(changed=False, filename="vyos_ospfv2_config.cfg")
gather_dict = {
"areas": [
{
@@ -378,9 +371,7 @@ set protocols ospf redistribute bgp metric-type '2'"""
"router_id": "192.0.1.1",
},
"passive_interface": ["eth2", "eth1"],
- "redistribute": [
- {"metric": 10, "metric_type": 2, "route_type": "bgp"}
- ],
+ "redistribute": [{"metric": 10, "metric_type": 2, "route_type": "bgp"}],
}
self.assertEqual(sorted(parsed_list), sorted(result["parsed"]))
@@ -430,6 +421,4 @@ set protocols ospf redistribute bgp metric-type '2'"""
"set protocols ospf area 4 network 192.0.2.0/24",
]
result = self.execute_module(changed=False)
- self.assertEqual(
- sorted(result["rendered"]), sorted(commands), result["rendered"]
- )
+ self.assertEqual(sorted(result["rendered"]), sorted(commands), result["rendered"])
diff --git a/tests/unit/modules/network/vyos/test_vyos_ospfv3.py b/tests/unit/modules/network/vyos/test_vyos_ospfv3.py
index ec47461..d04b7f7 100644
--- a/tests/unit/modules/network/vyos/test_vyos_ospfv3.py
+++ b/tests/unit/modules/network/vyos/test_vyos_ospfv3.py
@@ -20,11 +20,10 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
-from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
from ansible_collections.vyos.vyos.plugins.modules import vyos_ospfv3
-from ansible_collections.vyos.vyos.tests.unit.modules.utils import (
- set_module_args,
-)
+from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
+from ansible_collections.vyos.vyos.tests.unit.modules.utils import set_module_args
+
from .vyos_module import TestVyosModule, load_fixture
@@ -47,16 +46,12 @@ class TestVyosOspfv3Module(TestVyosModule):
self.mock_get_resource_connection_config = patch(
"ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection"
)
- self.get_resource_connection_config = (
- self.mock_get_resource_connection_config.start()
- )
+ self.get_resource_connection_config = self.mock_get_resource_connection_config.start()
self.mock_get_resource_connection_facts = patch(
"ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection"
)
- self.get_resource_connection_facts = (
- self.mock_get_resource_connection_facts.start()
- )
+ self.get_resource_connection_facts = self.mock_get_resource_connection_facts.start()
self.mock_execute_show_command = patch(
"ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.ospfv3.ospfv3.Ospfv3Facts.get_device_data"
@@ -254,9 +249,7 @@ class TestVyosOspfv3Module(TestVyosModule):
def test_vyos_ospfv3_gathered(self):
set_module_args(dict(state="gathered"))
- result = self.execute_module(
- changed=False, filename="vyos_ospfv3_config.cfg"
- )
+ result = self.execute_module(changed=False, filename="vyos_ospfv3_config.cfg")
gather_dict = {
"areas": [
{
@@ -343,6 +336,4 @@ set protocols ospfv3 redistribute 'bgp'"""
"set protocols ospfv3 area 3 range 2001:db40::/32",
]
result = self.execute_module(changed=False)
- self.assertEqual(
- sorted(result["rendered"]), sorted(commands), result["rendered"]
- )
+ self.assertEqual(sorted(result["rendered"]), sorted(commands), result["rendered"])
diff --git a/tests/unit/modules/network/vyos/test_vyos_ping.py b/tests/unit/modules/network/vyos/test_vyos_ping.py
index 9b79ce6..ea8d259 100644
--- a/tests/unit/modules/network/vyos/test_vyos_ping.py
+++ b/tests/unit/modules/network/vyos/test_vyos_ping.py
@@ -20,11 +20,10 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
-from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
from ansible_collections.vyos.vyos.plugins.modules import vyos_ping
-from ansible_collections.vyos.vyos.tests.unit.modules.utils import (
- set_module_args,
-)
+from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
+from ansible_collections.vyos.vyos.tests.unit.modules.utils import set_module_args
+
from .vyos_module import TestVyosModule, load_fixture
diff --git a/tests/unit/modules/network/vyos/test_vyos_prefix_lists.py b/tests/unit/modules/network/vyos/test_vyos_prefix_lists.py
index d1e1a8c..e8d044d 100644
--- a/tests/unit/modules/network/vyos/test_vyos_prefix_lists.py
+++ b/tests/unit/modules/network/vyos/test_vyos_prefix_lists.py
@@ -21,11 +21,11 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
from textwrap import dedent
-from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
+
from ansible_collections.vyos.vyos.plugins.modules import vyos_prefix_lists
-from ansible_collections.vyos.vyos.tests.unit.modules.utils import (
- set_module_args,
-)
+from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
+from ansible_collections.vyos.vyos.tests.unit.modules.utils import set_module_args
+
from .vyos_module import TestVyosModule
@@ -50,9 +50,7 @@ class TestVyosPrefixListsModule(TestVyosModule):
self.mock_get_resource_connection = patch(
"ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection"
)
- self.get_resource_connection = (
- self.mock_get_resource_connection.start()
- )
+ self.get_resource_connection = self.mock_get_resource_connection.start()
self.mock_get_config = patch(
"ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.prefix_lists.prefix_lists.Prefix_listsFacts.get_config"
diff --git a/tests/unit/modules/network/vyos/test_vyos_route_maps.py b/tests/unit/modules/network/vyos/test_vyos_route_maps.py
index d11e5ab..6b50ad5 100644
--- a/tests/unit/modules/network/vyos/test_vyos_route_maps.py
+++ b/tests/unit/modules/network/vyos/test_vyos_route_maps.py
@@ -20,11 +20,10 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
-from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
from ansible_collections.vyos.vyos.plugins.modules import vyos_route_maps
-from ansible_collections.vyos.vyos.tests.unit.modules.utils import (
- set_module_args,
-)
+from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
+from ansible_collections.vyos.vyos.tests.unit.modules.utils import set_module_args
+
from .vyos_module import TestVyosModule, load_fixture
@@ -38,16 +37,12 @@ class TestVyosRouteMapsModule(TestVyosModule):
self.mock_get_resource_connection_config = patch(
"ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection"
)
- self.get_resource_connection_config = (
- self.mock_get_resource_connection_config.start()
- )
+ self.get_resource_connection_config = self.mock_get_resource_connection_config.start()
self.mock_get_resource_connection_facts = patch(
"ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection"
)
- self.get_resource_connection_facts = (
- self.mock_get_resource_connection_facts.start()
- )
+ self.get_resource_connection_facts = self.mock_get_resource_connection_facts.start()
self.mock_execute_show_command = patch(
"ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.route_maps.route_maps.Route_mapsFacts.get_config"
diff --git a/tests/unit/modules/network/vyos/test_vyos_snmp_server.py b/tests/unit/modules/network/vyos/test_vyos_snmp_server.py
index 6cac77d..60a0746 100644
--- a/tests/unit/modules/network/vyos/test_vyos_snmp_server.py
+++ b/tests/unit/modules/network/vyos/test_vyos_snmp_server.py
@@ -20,11 +20,10 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
-from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
from ansible_collections.vyos.vyos.plugins.modules import vyos_snmp_server
-from ansible_collections.vyos.vyos.tests.unit.modules.utils import (
- set_module_args,
-)
+from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
+from ansible_collections.vyos.vyos.tests.unit.modules.utils import set_module_args
+
from .vyos_module import TestVyosModule, load_fixture
@@ -38,16 +37,12 @@ class TestVyosSnmpServerModule(TestVyosModule):
self.mock_get_resource_connection_config = patch(
"ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection"
)
- self.get_resource_connection_config = (
- self.mock_get_resource_connection_config.start()
- )
+ self.get_resource_connection_config = self.mock_get_resource_connection_config.start()
self.mock_get_resource_connection_facts = patch(
"ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection"
)
- self.get_resource_connection_facts = (
- self.mock_get_resource_connection_facts.start()
- )
+ self.get_resource_connection_facts = self.mock_get_resource_connection_facts.start()
self.mock_execute_show_command = patch(
"ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.snmp_server.snmp_server.Snmp_serverFacts.get_config"
@@ -89,21 +84,13 @@ class TestVyosSnmpServerModule(TestVyosModule):
users=[
dict(
user="admin_user",
- authentication=dict(
- type="sha", plaintext_key="abc1234567"
- ),
- privacy=dict(
- type="aes", plaintext_key="abc1234567"
- ),
+ authentication=dict(type="sha", plaintext_key="abc1234567"),
+ privacy=dict(type="aes", plaintext_key="abc1234567"),
),
dict(
user="guest_user",
- authentication=dict(
- type="sha", plaintext_key="opq1234567"
- ),
- privacy=dict(
- type="aes", plaintext_key="opq1234567"
- ),
+ authentication=dict(type="sha", plaintext_key="opq1234567"),
+ privacy=dict(type="aes", plaintext_key="opq1234567"),
),
]
),
@@ -131,21 +118,13 @@ class TestVyosSnmpServerModule(TestVyosModule):
users=[
dict(
user="admin_user",
- authentication=dict(
- type="sha", plaintext_key="abc1234567"
- ),
- privacy=dict(
- type="aes", plaintext_key="abc1234567"
- ),
+ authentication=dict(type="sha", plaintext_key="abc1234567"),
+ privacy=dict(type="aes", plaintext_key="abc1234567"),
),
dict(
user="guest_user",
- authentication=dict(
- type="sha", plaintext_key="opq1234567"
- ),
- privacy=dict(
- type="aes", plaintext_key="opq1234567"
- ),
+ authentication=dict(type="sha", plaintext_key="opq1234567"),
+ privacy=dict(type="aes", plaintext_key="opq1234567"),
),
]
),
@@ -173,21 +152,13 @@ class TestVyosSnmpServerModule(TestVyosModule):
users=[
dict(
user="admin_user",
- authentication=dict(
- type="sha", plaintext_key="abc1234567"
- ),
- privacy=dict(
- type="aes", plaintext_key="abc1234567"
- ),
+ authentication=dict(type="sha", plaintext_key="abc1234567"),
+ privacy=dict(type="aes", plaintext_key="abc1234567"),
),
dict(
user="guest_user",
- authentication=dict(
- type="sha", plaintext_key="opq1234567"
- ),
- privacy=dict(
- type="aes", plaintext_key="opq1234567"
- ),
+ authentication=dict(type="sha", plaintext_key="opq1234567"),
+ privacy=dict(type="aes", plaintext_key="opq1234567"),
),
]
),
@@ -213,9 +184,7 @@ class TestVyosSnmpServerModule(TestVyosModule):
description="snmp_config",
smux_peer="peer1",
trap_source="1.1.1.1",
- trap_target=dict(
- address="10.10.1.1", community="switches", port="80"
- ),
+ trap_target=dict(address="10.10.1.1", community="switches", port="80"),
snmp_v3=dict(
engine_id="34",
groups=[
@@ -229,12 +198,8 @@ class TestVyosSnmpServerModule(TestVyosModule):
trap_targets=[
dict(
address="20.12.1.1",
- authentication=dict(
- type="sha", plaintext_key="abc1234567"
- ),
- privacy=dict(
- type="aes", plaintext_key="abc1234567"
- ),
+ authentication=dict(type="sha", plaintext_key="abc1234567"),
+ privacy=dict(type="aes", plaintext_key="abc1234567"),
),
],
),
@@ -275,9 +240,7 @@ class TestVyosSnmpServerModule(TestVyosModule):
description="snmp_config",
smux_peer="peer1",
trap_source="1.1.1.1",
- trap_target=dict(
- address="10.10.1.1", community="switches", port="80"
- ),
+ trap_target=dict(address="10.10.1.1", community="switches", port="80"),
snmp_v3=dict(
engine_id="34",
groups=[
@@ -291,12 +254,8 @@ class TestVyosSnmpServerModule(TestVyosModule):
trap_targets=[
dict(
address="20.12.1.1",
- authentication=dict(
- type="sha", plaintext_key="abc1234567"
- ),
- privacy=dict(
- type="aes", plaintext_key="abc1234567"
- ),
+ authentication=dict(type="sha", plaintext_key="abc1234567"),
+ privacy=dict(type="aes", plaintext_key="abc1234567"),
),
],
),
@@ -350,9 +309,7 @@ class TestVyosSnmpServerModule(TestVyosModule):
description="snmp_config",
smux_peer="peer1",
trap_source="1.1.1.1",
- trap_target=dict(
- address="10.10.1.1", community="switches", port="80"
- ),
+ trap_target=dict(address="10.10.1.1", community="switches", port="80"),
snmp_v3=dict(
engine_id="34",
groups=[
@@ -366,12 +323,8 @@ class TestVyosSnmpServerModule(TestVyosModule):
trap_targets=[
dict(
address="20.12.1.1",
- authentication=dict(
- type="sha", plaintext_key="abc1234567"
- ),
- privacy=dict(
- type="aes", plaintext_key="abc1234567"
- ),
+ authentication=dict(type="sha", plaintext_key="abc1234567"),
+ privacy=dict(type="aes", plaintext_key="abc1234567"),
),
],
),
@@ -434,9 +387,7 @@ class TestVyosSnmpServerModule(TestVyosModule):
description="snmp_config",
smux_peer="peer1",
trap_source="1.1.1.1",
- trap_target=dict(
- address="10.10.1.1", community="switches", port="80"
- ),
+ trap_target=dict(address="10.10.1.1", community="switches", port="80"),
snmp_v3=dict(
engine_id="34",
groups=[
@@ -450,12 +401,8 @@ class TestVyosSnmpServerModule(TestVyosModule):
trap_targets=[
dict(
address="20.12.1.1",
- authentication=dict(
- type="sha", plaintext_key="abc1234567"
- ),
- privacy=dict(
- type="aes", plaintext_key="abc1234567"
- ),
+ authentication=dict(type="sha", plaintext_key="abc1234567"),
+ privacy=dict(type="aes", plaintext_key="abc1234567"),
),
],
),
diff --git a/tests/unit/modules/network/vyos/test_vyos_static_routes.py b/tests/unit/modules/network/vyos/test_vyos_static_routes.py
index 5577d9c..df25992 100644
--- a/tests/unit/modules/network/vyos/test_vyos_static_routes.py
+++ b/tests/unit/modules/network/vyos/test_vyos_static_routes.py
@@ -20,11 +20,10 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
-from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
from ansible_collections.vyos.vyos.plugins.modules import vyos_static_routes
-from ansible_collections.vyos.vyos.tests.unit.modules.utils import (
- set_module_args,
-)
+from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
+from ansible_collections.vyos.vyos.tests.unit.modules.utils import set_module_args
+
from .vyos_module import TestVyosModule, load_fixture
@@ -47,16 +46,12 @@ class TestVyosStaticRoutesModule(TestVyosModule):
self.mock_get_resource_connection_config = patch(
"ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection"
)
- self.get_resource_connection_config = (
- self.mock_get_resource_connection_config.start()
- )
+ self.get_resource_connection_config = self.mock_get_resource_connection_config.start()
self.mock_get_resource_connection_facts = patch(
"ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection"
)
- self.get_resource_connection_facts = (
- self.mock_get_resource_connection_facts.start()
- )
+ self.get_resource_connection_facts = self.mock_get_resource_connection_facts.start()
self.mock_execute_show_command = patch(
"ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.static_routes.static_routes.Static_routesFacts.get_device_data"
@@ -128,12 +123,8 @@ class TestVyosStaticRoutesModule(TestVyosModule):
dict(
dest="192.0.2.32/28",
next_hops=[
- dict(
- forward_router_address="192.0.2.9"
- ),
- dict(
- forward_router_address="192.0.2.10"
- ),
+ dict(forward_router_address="192.0.2.9"),
+ dict(forward_router_address="192.0.2.10"),
],
)
],
@@ -197,12 +188,8 @@ class TestVyosStaticRoutesModule(TestVyosModule):
dict(
dest="192.0.2.32/28",
next_hops=[
- dict(
- forward_router_address="192.0.2.9"
- ),
- dict(
- forward_router_address="192.0.2.10"
- ),
+ dict(forward_router_address="192.0.2.9"),
+ dict(forward_router_address="192.0.2.10"),
],
)
],
@@ -228,12 +215,8 @@ class TestVyosStaticRoutesModule(TestVyosModule):
dict(
dest="192.0.2.48/28",
next_hops=[
- dict(
- forward_router_address="192.0.2.9"
- ),
- dict(
- forward_router_address="192.0.2.10"
- ),
+ dict(forward_router_address="192.0.2.9"),
+ dict(forward_router_address="192.0.2.10"),
],
)
],
@@ -264,12 +247,8 @@ class TestVyosStaticRoutesModule(TestVyosModule):
dict(
dest="192.0.2.32/28",
next_hops=[
- dict(
- forward_router_address="192.0.2.9"
- ),
- dict(
- forward_router_address="192.0.2.10"
- ),
+ dict(forward_router_address="192.0.2.9"),
+ dict(forward_router_address="192.0.2.10"),
],
)
],
diff --git a/tests/unit/modules/network/vyos/test_vyos_system.py b/tests/unit/modules/network/vyos/test_vyos_system.py
index b763d9c..3665720 100644
--- a/tests/unit/modules/network/vyos/test_vyos_system.py
+++ b/tests/unit/modules/network/vyos/test_vyos_system.py
@@ -20,11 +20,10 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
-from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
from ansible_collections.vyos.vyos.plugins.modules import vyos_system
-from ansible_collections.vyos.vyos.tests.unit.modules.utils import (
- set_module_args,
-)
+from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
+from ansible_collections.vyos.vyos.tests.unit.modules.utils import set_module_args
+
from .vyos_module import TestVyosModule, load_fixture
@@ -80,9 +79,7 @@ class TestVyosSystemModule(TestVyosModule):
self.execute_module(changed=True, commands=commands)
def test_vyos_system_domain_search(self):
- set_module_args(
- dict(domain_search=["foo.example.com", "bar.example.com"])
- )
+ set_module_args(dict(domain_search=["foo.example.com", "bar.example.com"]))
commands = [
"set system domain-search domain 'foo.example.com'",
"set system domain-search domain 'bar.example.com'",
diff --git a/tests/unit/modules/network/vyos/test_vyos_user.py b/tests/unit/modules/network/vyos/test_vyos_user.py
index 427036b..5a1f69f 100644
--- a/tests/unit/modules/network/vyos/test_vyos_user.py
+++ b/tests/unit/modules/network/vyos/test_vyos_user.py
@@ -20,11 +20,10 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
-from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
from ansible_collections.vyos.vyos.plugins.modules import vyos_user
-from ansible_collections.vyos.vyos.tests.unit.modules.utils import (
- set_module_args,
-)
+from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
+from ansible_collections.vyos.vyos.tests.unit.modules.utils import set_module_args
+
from .vyos_module import TestVyosModule, load_fixture
@@ -59,17 +58,13 @@ class TestVyosUserModule(TestVyosModule):
result = self.execute_module(changed=True)
self.assertEqual(
result["commands"],
- [
- "set system login user ansible authentication plaintext-password test"
- ],
+ ["set system login user ansible authentication plaintext-password test"],
)
def test_vyos_user_delete(self):
set_module_args(dict(name="ansible", state="absent"))
result = self.execute_module(changed=True)
- self.assertEqual(
- result["commands"], ["delete system login user ansible"]
- )
+ self.assertEqual(result["commands"], ["delete system login user ansible"])
def test_vyos_user_level(self):
set_module_args(dict(name="ansible", level="operator"))
@@ -107,9 +102,7 @@ class TestVyosUserModule(TestVyosModule):
result = self.execute_module(changed=True)
self.assertEqual(
result["commands"],
- [
- "set system login user test authentication plaintext-password test"
- ],
+ ["set system login user test authentication plaintext-password test"],
)
def test_vyos_user_update_password_on_create_ok(self):
@@ -133,7 +126,5 @@ class TestVyosUserModule(TestVyosModule):
result = self.execute_module(changed=True)
self.assertEqual(
result["commands"],
- [
- "set system login user ansible authentication plaintext-password test"
- ],
+ ["set system login user ansible authentication plaintext-password test"],
)
diff --git a/tests/unit/modules/network/vyos/vyos_module.py b/tests/unit/modules/network/vyos/vyos_module.py
index cb7874f..98a422d 100644
--- a/tests/unit/modules/network/vyos/vyos_module.py
+++ b/tests/unit/modules/network/vyos/vyos_module.py
@@ -20,8 +20,8 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
-import os
import json
+import os
from ansible_collections.vyos.vyos.tests.unit.modules.utils import (
AnsibleExitJson,
@@ -29,7 +29,6 @@ from ansible_collections.vyos.vyos.tests.unit.modules.utils import (
ModuleTestCase,
)
-
fixture_path = os.path.join(os.path.dirname(__file__), "fixtures")
fixture_data = {}
@@ -83,9 +82,7 @@ class TestVyosModule(ModuleTestCase):
result["commands"],
)
else:
- self.assertEqual(
- commands, result["commands"], result["commands"]
- )
+ self.assertEqual(commands, result["commands"], result["commands"])
return result
diff --git a/tests/unit/modules/utils.py b/tests/unit/modules/utils.py
index 90023ce..779c68f 100644
--- a/tests/unit/modules/utils.py
+++ b/tests/unit/modules/utils.py
@@ -3,11 +3,12 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
import json
-from ansible_collections.vyos.vyos.tests.unit.compat import unittest
-from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
from ansible.module_utils import basic
from ansible.module_utils._text import to_bytes
+from ansible_collections.vyos.vyos.tests.unit.compat import unittest
+from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
+
def set_module_args(args):
if "_ansible_remote_tmp" not in args: