summaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/mock/loader.py1
-rw-r--r--tests/unit/mock/path.py2
-rw-r--r--tests/unit/mock/procenv.py2
-rw-r--r--tests/unit/mock/vault_helper.py1
-rw-r--r--tests/unit/mock/yaml_helper.py10
-rw-r--r--tests/unit/modules/conftest.py2
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_banner.py5
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_bgp_address_family.py43
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_bgp_global.py25
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_command.py3
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_config.py15
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_facts.py8
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_firewall_global.py35
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_firewall_interfaces.py31
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_firewall_rules.py137
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_hostname.py7
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_interfaces.py21
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_logging_global.py45
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_ntp_global.py23
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_ospf_interfaces.py27
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_ospfv2.py29
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_ospfv3.py23
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_ping.py3
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_prefix_lists.py69
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_route_maps.py49
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_snmp_server.py47
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_static_routes.py73
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_system.py7
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_user.py13
-rw-r--r--tests/unit/modules/network/vyos/vyos_module.py2
-rw-r--r--tests/unit/modules/utils.py6
31 files changed, 404 insertions, 360 deletions
diff --git a/tests/unit/mock/loader.py b/tests/unit/mock/loader.py
index 2828f38..67b84c6 100644
--- a/tests/unit/mock/loader.py
+++ b/tests/unit/mock/loader.py
@@ -18,6 +18,7 @@
# Make coding more python3-ish
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
import os
diff --git a/tests/unit/mock/path.py b/tests/unit/mock/path.py
index 3962f24..1f1b7f0 100644
--- a/tests/unit/mock/path.py
+++ b/tests/unit/mock/path.py
@@ -1,8 +1,10 @@
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
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)
diff --git a/tests/unit/mock/procenv.py b/tests/unit/mock/procenv.py
index 06987e3..d7f3dc9 100644
--- a/tests/unit/mock/procenv.py
+++ b/tests/unit/mock/procenv.py
@@ -19,10 +19,12 @@
# Make coding more python3-ish
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
import json
import sys
+
from contextlib import contextmanager
from io import BytesIO, StringIO
diff --git a/tests/unit/mock/vault_helper.py b/tests/unit/mock/vault_helper.py
index 4c6c890..6006ba9 100644
--- a/tests/unit/mock/vault_helper.py
+++ b/tests/unit/mock/vault_helper.py
@@ -14,6 +14,7 @@
# Make coding more python3-ish
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
from ansible.module_utils._text import to_bytes
diff --git a/tests/unit/mock/yaml_helper.py b/tests/unit/mock/yaml_helper.py
index 540055d..2e85759 100644
--- a/tests/unit/mock/yaml_helper.py
+++ b/tests/unit/mock/yaml_helper.py
@@ -1,9 +1,11 @@
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
import io
import yaml
+
from ansible.module_utils.six import PY3
from ansible.parsing.yaml.dumper import AnsibleDumper
from ansible.parsing.yaml.loader import AnsibleLoader
@@ -115,10 +117,14 @@ class YamlTestUtils(object):
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
+ obj_from_stream,
+ Dumper=AnsibleDumper,
+ encoding=None,
)
yaml_string_obj_from_string = yaml.dump(
- obj_from_string, Dumper=AnsibleDumper, encoding=None
+ obj_from_string,
+ Dumper=AnsibleDumper,
+ encoding=None,
)
assert yaml_string == yaml_string_obj_from_stream
diff --git a/tests/unit/modules/conftest.py b/tests/unit/modules/conftest.py
index 013d198..41465c3 100644
--- a/tests/unit/modules/conftest.py
+++ b/tests/unit/modules/conftest.py
@@ -2,11 +2,13 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
import json
import pytest
+
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
diff --git a/tests/unit/modules/network/vyos/test_vyos_banner.py b/tests/unit/modules/network/vyos/test_vyos_banner.py
index f054ee0..d418a27 100644
--- a/tests/unit/modules/network/vyos/test_vyos_banner.py
+++ b/tests/unit/modules/network/vyos/test_vyos_banner.py
@@ -16,6 +16,7 @@
# Make coding more python3-ish
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
from unittest.mock import patch
@@ -33,12 +34,12 @@ class TestVyosBannerModule(TestVyosModule):
super(TestVyosBannerModule, self).setUp()
self.mock_get_config = patch(
- "ansible_collections.vyos.vyos.plugins.modules.vyos_banner.get_config"
+ "ansible_collections.vyos.vyos.plugins.modules.vyos_banner.get_config",
)
self.get_config = self.mock_get_config.start()
self.mock_load_config = patch(
- "ansible_collections.vyos.vyos.plugins.modules.vyos_banner.load_config"
+ "ansible_collections.vyos.vyos.plugins.modules.vyos_banner.load_config",
)
self.load_config = self.mock_load_config.start()
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 9ef28aa..87b3ad9 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
@@ -18,6 +18,7 @@
# Make coding more python3-ish
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
from unittest.mock import patch
@@ -34,13 +35,13 @@ class TestVyosBgpafModule(TestVyosModule):
def setUp(self):
super(TestVyosBgpafModule, self).setUp()
self.mock_get_resource_connection_config = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection"
+ "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.mock_execute_show_command = patch(
"ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts."
- + "bgp_address_family.bgp_address_family.Bgp_address_familyFacts.get_device_data"
+ + "bgp_address_family.bgp_address_family.Bgp_address_familyFacts.get_device_data",
)
self.execute_show_command = self.mock_execute_show_command.start()
@@ -95,12 +96,12 @@ class TestVyosBgpafModule(TestVyosModule):
dict(
afi="ipv6",
attribute_unchanged=dict(next_hop=True),
- )
+ ),
],
),
],
- )
- )
+ ),
+ ),
)
self.execute_module(changed=False, commands=[])
@@ -142,12 +143,12 @@ class TestVyosBgpafModule(TestVyosModule):
dict(action="export", path_list="list01"),
],
capability=dict(orf="send"),
- )
+ ),
],
),
],
- )
- )
+ ),
+ ),
)
commands = [
"set protocols bgp 65536 address-family ipv4-unicast aggregate-address 192.0.2.0/24 as-setipv4-unicast aggregate-address 192.0.2.0/24 summary-only",
@@ -196,12 +197,12 @@ class TestVyosBgpafModule(TestVyosModule):
dict(
afi="ipv6",
attribute_unchanged=dict(next_hop=True),
- )
+ ),
],
),
],
),
- )
+ ),
)
self.execute_module(changed=False, commands=[])
@@ -257,12 +258,12 @@ class TestVyosBgpafModule(TestVyosModule):
dict(action="export", path_list="list01"),
],
capability=dict(orf="send"),
- )
+ ),
],
),
],
),
- )
+ ),
)
commands = [
"delete protocols bgp 65536 neighbor 203.0.113.5 address-family ipv6-unicast attribute-unchanged",
@@ -316,12 +317,12 @@ class TestVyosBgpafModule(TestVyosModule):
dict(
afi="ipv6",
attribute_unchanged=dict(next_hop=True),
- )
+ ),
],
),
],
),
- )
+ ),
)
self.execute_module(changed=False, commands=[])
@@ -360,7 +361,7 @@ class TestVyosBgpafModule(TestVyosModule):
),
],
),
- )
+ ),
)
commands = [
"delete protocols bgp 65536 neighbor 203.0.113.5 address-family",
@@ -400,7 +401,7 @@ class TestVyosBgpafModule(TestVyosModule):
),
],
),
- )
+ ),
)
commands = [
"delete protocols bgp 65536 address-family ipv4-unicast",
@@ -445,7 +446,7 @@ class TestVyosBgpafModule(TestVyosModule):
),
],
),
- )
+ ),
)
result = self.execute_module(failed=True)
self.assertIn("Only one bgp instance is allowed per device", result["msg"])
@@ -487,12 +488,12 @@ class TestVyosBgpafModule(TestVyosModule):
dict(
afi="ipv6",
attribute_unchanged=dict(next_hop=True),
- )
+ ),
],
),
],
),
- )
+ ),
)
rendered_cmds = [
@@ -554,7 +555,7 @@ class TestVyosBgpafModule(TestVyosModule):
{
"afi": "ipv6",
"attribute_unchanged": {"next_hop": True},
- }
+ },
],
},
],
@@ -593,7 +594,7 @@ class TestVyosBgpafModule(TestVyosModule):
{
"afi": "ipv6",
"attribute_unchanged": {"next_hop": True},
- }
+ },
],
},
],
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 830fd38..99d17ce 100644
--- a/tests/unit/modules/network/vyos/test_vyos_bgp_global.py
+++ b/tests/unit/modules/network/vyos/test_vyos_bgp_global.py
@@ -18,6 +18,7 @@
# Make coding more python3-ish
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
from unittest.mock import patch
@@ -35,22 +36,22 @@ class TestVyosBgpglobalModule(TestVyosModule):
super(TestVyosBgpglobalModule, self).setUp()
self.mock_get_resource_connection_config = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection"
+ "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.mock_execute_show_command_config = patch(
- "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.config.bgp_global.bgp_global.Bgp_global._get_config"
+ "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.mock_get_resource_connection_facts = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection"
+ "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.mock_execute_show_command = patch(
- "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.bgp_global.bgp_global.Bgp_globalFacts.get_device_data"
+ "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.bgp_global.bgp_global.Bgp_globalFacts.get_device_data",
)
self.execute_show_command = self.mock_execute_show_command.start()
@@ -117,7 +118,7 @@ class TestVyosBgpglobalModule(TestVyosModule):
],
),
state="merged",
- )
+ ),
)
self.execute_module(changed=False, commands=[])
@@ -141,7 +142,7 @@ class TestVyosBgpglobalModule(TestVyosModule):
dict(action="export", acl=31),
dict(action="import", acl=9),
],
- )
+ ),
],
bgp_params=dict(
confederation=[dict(peers=20), dict(identifier=66)],
@@ -149,7 +150,7 @@ class TestVyosBgpglobalModule(TestVyosModule):
),
),
state="merged",
- )
+ ),
)
commands = [
"set protocols bgp 65536 neighbor 2001:db8::2 distribute-list export 31",
@@ -205,7 +206,7 @@ class TestVyosBgpglobalModule(TestVyosModule):
],
),
state="replaced",
- )
+ ),
)
self.execute_module(changed=False, commands=[])
@@ -242,7 +243,7 @@ class TestVyosBgpglobalModule(TestVyosModule):
),
),
state="replaced",
- )
+ ),
)
commands = [
"delete protocols bgp 65536 parameters default",
@@ -308,7 +309,7 @@ class TestVyosBgpglobalModule(TestVyosModule):
),
),
state="replaced",
- )
+ ),
)
result = self.execute_module(failed=True)
self.assertIn("Only one bgp instance is allowed per device", result["msg"])
@@ -345,7 +346,7 @@ class TestVyosBgpglobalModule(TestVyosModule):
),
),
state="replaced",
- )
+ ),
)
result = self.execute_module(failed=True, filename="vyos_bgp_global_af_config.cfg")
self.assertIn(
@@ -397,7 +398,7 @@ class TestVyosBgpglobalModule(TestVyosModule):
],
),
state="rendered",
- )
+ ),
)
rendered_cmds = [
"set protocols bgp 65536 neighbor 10.0.0.4 disable-connected-check",
diff --git a/tests/unit/modules/network/vyos/test_vyos_command.py b/tests/unit/modules/network/vyos/test_vyos_command.py
index 40db158..2c7cd32 100644
--- a/tests/unit/modules/network/vyos/test_vyos_command.py
+++ b/tests/unit/modules/network/vyos/test_vyos_command.py
@@ -18,6 +18,7 @@
# Make coding more python3-ish
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
from unittest.mock import patch
@@ -34,7 +35,7 @@ class TestVyosCommandModule(TestVyosModule):
def setUp(self):
super(TestVyosCommandModule, self).setUp()
self.mock_run_commands = patch(
- "ansible_collections.vyos.vyos.plugins.modules.vyos_command.run_commands"
+ "ansible_collections.vyos.vyos.plugins.modules.vyos_command.run_commands",
)
self.run_commands = self.mock_run_commands.start()
diff --git a/tests/unit/modules/network/vyos/test_vyos_config.py b/tests/unit/modules/network/vyos/test_vyos_config.py
index 743acab..4f1cac6 100644
--- a/tests/unit/modules/network/vyos/test_vyos_config.py
+++ b/tests/unit/modules/network/vyos/test_vyos_config.py
@@ -19,6 +19,7 @@
# Make coding more python3-ish
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
from unittest.mock import MagicMock, patch
@@ -37,22 +38,22 @@ class TestVyosConfigModule(TestVyosModule):
super(TestVyosConfigModule, self).setUp()
self.mock_get_config = patch(
- "ansible_collections.vyos.vyos.plugins.modules.vyos_config.get_config"
+ "ansible_collections.vyos.vyos.plugins.modules.vyos_config.get_config",
)
self.get_config = self.mock_get_config.start()
self.mock_load_config = patch(
- "ansible_collections.vyos.vyos.plugins.modules.vyos_config.load_config"
+ "ansible_collections.vyos.vyos.plugins.modules.vyos_config.load_config",
)
self.load_config = self.mock_load_config.start()
self.mock_run_commands = patch(
- "ansible_collections.vyos.vyos.plugins.modules.vyos_config.run_commands"
+ "ansible_collections.vyos.vyos.plugins.modules.vyos_config.run_commands",
)
self.run_commands = self.mock_run_commands.start()
self.mock_get_connection = patch(
- "ansible_collections.vyos.vyos.plugins.modules.vyos_config.get_connection"
+ "ansible_collections.vyos.vyos.plugins.modules.vyos_config.get_connection",
)
self.get_connection = self.mock_get_connection.start()
@@ -91,7 +92,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)
@@ -116,7 +117,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)
@@ -136,6 +137,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 691d7cf..dd3a796 100644
--- a/tests/unit/modules/network/vyos/test_vyos_facts.py
+++ b/tests/unit/modules/network/vyos/test_vyos_facts.py
@@ -17,8 +17,10 @@
# Make coding more python3-ish
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
import json
+
from unittest.mock import patch
from ansible_collections.vyos.vyos.plugins.modules import vyos_facts
@@ -33,17 +35,17 @@ class TestVyosFactsModule(TestVyosModule):
def setUp(self):
super(TestVyosFactsModule, self).setUp()
self.mock_run_commands = patch(
- "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.legacy.base.run_commands"
+ "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.legacy.base.run_commands",
)
self.run_commands = self.mock_run_commands.start()
self.mock_get_resource_connection = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection"
+ "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.mock_get_capabilities = patch(
- "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.legacy.base.get_capabilities"
+ "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.legacy.base.get_capabilities",
)
self.get_capabilities = self.mock_get_capabilities.start()
self.get_capabilities.return_value = {
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 71b3a18..25c5632 100644
--- a/tests/unit/modules/network/vyos/test_vyos_firewall_global.py
+++ b/tests/unit/modules/network/vyos/test_vyos_firewall_global.py
@@ -18,6 +18,7 @@
# Make coding more python3-ish
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
from unittest.mock import patch
@@ -34,27 +35,27 @@ class TestVyosFirewallRulesModule(TestVyosModule):
def setUp(self):
super(TestVyosFirewallRulesModule, self).setUp()
self.mock_get_config = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config"
+ "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config",
)
self.get_config = self.mock_get_config.start()
self.mock_load_config = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config"
+ "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config",
)
self.load_config = self.mock_load_config.start()
self.mock_get_resource_connection_config = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection"
+ "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.mock_get_resource_connection_facts = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection"
+ "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.mock_execute_show_command = patch(
- "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.firewall_global.firewall_global.Firewall_globalFacts.get_device_data"
+ "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.firewall_global.firewall_global.Firewall_globalFacts.get_device_data",
)
self.execute_show_command = self.mock_execute_show_command.start()
@@ -96,7 +97,7 @@ class TestVyosFirewallRulesModule(TestVyosModule):
afi="ipv4",
ip_src_route=True,
icmp_redirects=dict(send=True, receive=False),
- )
+ ),
],
group=dict(
address_group=[
@@ -141,12 +142,12 @@ class TestVyosFirewallRulesModule(TestVyosModule):
name="TELNET",
description="This group has the telnet ports",
members=[dict(port="23")],
- )
+ ),
],
),
),
state="merged",
- )
+ ),
)
commands = [
"set firewall group address-group MGMT-HOSTS address 192.0.1.1",
@@ -228,12 +229,12 @@ class TestVyosFirewallRulesModule(TestVyosModule):
name="SSH",
description="This group has the ssh ports",
members=[dict(port="22")],
- )
+ ),
],
- )
+ ),
),
state="merged",
- )
+ ),
)
self.execute_module(changed=False, commands=[])
@@ -282,12 +283,12 @@ class TestVyosFirewallRulesModule(TestVyosModule):
name="SSH",
description="This group has the ssh ports",
members=[dict(port="2222")],
- )
+ ),
],
- )
+ ),
),
state="replaced",
- )
+ ),
)
commands = [
"delete firewall group address-group RND-HOSTS address 192.0.2.3",
@@ -346,12 +347,12 @@ class TestVyosFirewallRulesModule(TestVyosModule):
name="SSH",
description="This group has the ssh ports",
members=[dict(port="22")],
- )
+ ),
],
- )
+ ),
),
state="replaced",
- )
+ ),
)
self.execute_module(changed=False, commands=[])
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 10d93ca..3034d58 100644
--- a/tests/unit/modules/network/vyos/test_vyos_firewall_interfaces.py
+++ b/tests/unit/modules/network/vyos/test_vyos_firewall_interfaces.py
@@ -18,6 +18,7 @@
# Make coding more python3-ish
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
from unittest.mock import patch
@@ -34,28 +35,28 @@ class TestVyosFirewallInterfacesModule(TestVyosModule):
def setUp(self):
super(TestVyosFirewallInterfacesModule, self).setUp()
self.mock_get_config = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config"
+ "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config",
)
self.get_config = self.mock_get_config.start()
self.mock_load_config = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config"
+ "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config",
)
self.load_config = self.mock_load_config.start()
self.mock_get_resource_connection_config = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection"
+ "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.mock_get_resource_connection_facts = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection"
+ "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.mock_execute_show_command = patch(
"ansible_collections.vyos.vyos.plugins.module_utils.network.vyos."
- "facts.firewall_interfaces.firewall_interfaces.Firewall_interfacesFacts.get_device_data"
+ "facts.firewall_interfaces.firewall_interfaces.Firewall_interfacesFacts.get_device_data",
)
self.execute_show_command = self.mock_execute_show_command.start()
@@ -113,7 +114,7 @@ class TestVyosFirewallInterfacesModule(TestVyosModule):
),
],
state="merged",
- )
+ ),
)
commands = [
"set interfaces ethernet eth1 firewall in name 'INBOUND'",
@@ -167,7 +168,7 @@ class TestVyosFirewallInterfacesModule(TestVyosModule):
),
],
state="merged",
- )
+ ),
)
self.execute_module(changed=False, commands=[])
@@ -178,10 +179,10 @@ class TestVyosFirewallInterfacesModule(TestVyosModule):
dict(
name="eth0",
access_rules=[dict(afi="ipv4"), dict(afi="ipv6")],
- )
+ ),
],
state="deleted",
- )
+ ),
)
commands = [
"delete interfaces ethernet eth0 firewall in name",
@@ -259,7 +260,7 @@ class TestVyosFirewallInterfacesModule(TestVyosModule):
),
],
state="replaced",
- )
+ ),
)
self.execute_module(changed=False, commands=[])
@@ -308,7 +309,7 @@ class TestVyosFirewallInterfacesModule(TestVyosModule):
),
],
state="replaced",
- )
+ ),
)
commands = [
"delete interfaces ethernet eth0 firewall out name",
@@ -330,12 +331,12 @@ class TestVyosFirewallInterfacesModule(TestVyosModule):
dict(
afi="ipv4",
rules=[dict(name="INBOUND", direction="in")],
- )
+ ),
],
- )
+ ),
],
state="overridden",
- )
+ ),
)
commands = [
"delete interfaces ethernet eth0 firewall",
@@ -384,6 +385,6 @@ class TestVyosFirewallInterfacesModule(TestVyosModule):
),
],
state="overridden",
- )
+ ),
)
self.execute_module(changed=False, commands=[])
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 18da678..b43b11c 100644
--- a/tests/unit/modules/network/vyos/test_vyos_firewall_rules.py
+++ b/tests/unit/modules/network/vyos/test_vyos_firewall_rules.py
@@ -18,6 +18,7 @@
# Make coding more python3-ish
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
from unittest.mock import patch
@@ -34,35 +35,35 @@ class TestVyosFirewallRulesModule(TestVyosModule):
def setUp(self):
super(TestVyosFirewallRulesModule, self).setUp()
self.mock_get_config = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config"
+ "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config",
)
self.get_config = self.mock_get_config.start()
self.mock_load_config = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config"
+ "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config",
)
self.load_config = self.mock_load_config.start()
self.mock_get_resource_connection_config = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection"
+ "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.mock_get_resource_connection_facts = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection"
+ "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.mock_execute_show_command = patch(
- "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.static_routes.static_routes.Static_routesFacts.get_device_data"
+ "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.static_routes.static_routes.Static_routesFacts.get_device_data",
)
self.mock_execute_show_command = patch(
- "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.firewall_rules.firewall_rules.Firewall_rulesFacts.get_device_data"
+ "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.firewall_rules.firewall_rules.Firewall_rulesFacts.get_device_data",
)
self.execute_show_command = self.mock_execute_show_command.start()
self.mock_get_os_version = patch(
- "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.config.firewall_rules.firewall_rules.Firewall_rules._get_os_version"
+ "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.config.firewall_rules.firewall_rules.Firewall_rules._get_os_version",
)
self.get_os_version = self.mock_get_os_version.start()
self.get_os_version.return_value = "Vyos 1.2"
@@ -126,7 +127,7 @@ class TestVyosFirewallRulesModule(TestVyosModule):
),
],
state="merged",
- )
+ ),
)
commands = [
"set firewall ipv6-name V6-INBOUND default-action 'reject'",
@@ -186,7 +187,7 @@ class TestVyosFirewallRulesModule(TestVyosModule):
),
],
state="merged",
- )
+ ),
)
commands = [
"set firewall ipv6-name V6-INBOUND default-action 'reject'",
@@ -224,14 +225,14 @@ class TestVyosFirewallRulesModule(TestVyosModule):
protocol="icmp",
fragment="match-frag",
disable=True,
- )
+ ),
],
),
],
- )
+ ),
],
state="merged",
- )
+ ),
)
commands = [
"set firewall name INBOUND default-action 'accept'",
@@ -278,14 +279,14 @@ class TestVyosFirewallRulesModule(TestVyosModule):
invalid=True,
new=True,
),
- )
+ ),
],
),
],
- )
+ ),
],
state="merged",
- )
+ ),
)
commands = [
"set firewall name INBOUND rule 101 protocol 'tcp'",
@@ -323,23 +324,23 @@ class TestVyosFirewallRulesModule(TestVyosModule):
address_group="OUT-ADDR-GROUP",
network_group="OUT-NET-GROUP",
port_group="OUT-PORT-GROUP",
- )
+ ),
),
source=dict(
group=dict(
address_group="IN-ADDR-GROUP",
network_group="IN-NET-GROUP",
port_group="IN-PORT-GROUP",
- )
+ ),
),
- )
+ ),
],
),
],
- )
+ ),
],
state="merged",
- )
+ ),
)
commands = [
"set firewall name INBOUND rule 101 source group address-group IN-ADDR-GROUP",
@@ -374,14 +375,14 @@ class TestVyosFirewallRulesModule(TestVyosModule):
utc=True,
),
tcp=dict(flags="ALL"),
- )
+ ),
],
),
],
- )
+ ),
],
state="merged",
- )
+ ),
)
commands = [
"set firewall name INBOUND rule 101",
@@ -417,14 +418,14 @@ class TestVyosFirewallRulesModule(TestVyosModule):
protocol="icmp",
disabled=True,
icmp=dict(type_name="echo-request"),
- )
+ ),
],
),
],
- )
+ ),
],
state="merged",
- )
+ ),
)
commands = [
"set firewall ipv6-name INBOUND default-action 'accept'",
@@ -470,14 +471,14 @@ class TestVyosFirewallRulesModule(TestVyosModule):
invalid=True,
new=True,
),
- )
+ ),
],
),
],
- )
+ ),
],
state="merged",
- )
+ ),
)
commands = [
"set firewall ipv6-name INBOUND rule 101 protocol 'tcp'",
@@ -515,23 +516,23 @@ class TestVyosFirewallRulesModule(TestVyosModule):
address_group="OUT-ADDR-GROUP",
network_group="OUT-NET-GROUP",
port_group="OUT-PORT-GROUP",
- )
+ ),
),
source=dict(
group=dict(
address_group="IN-ADDR-GROUP",
network_group="IN-NET-GROUP",
port_group="IN-PORT-GROUP",
- )
+ ),
),
- )
+ ),
],
),
],
- )
+ ),
],
state="merged",
- )
+ ),
)
commands = [
"set firewall ipv6-name INBOUND rule 101 source group address-group IN-ADDR-GROUP",
@@ -566,14 +567,14 @@ class TestVyosFirewallRulesModule(TestVyosModule):
utc=True,
),
tcp=dict(flags="ALL"),
- )
+ ),
],
),
],
- )
+ ),
],
state="merged",
- )
+ ),
)
commands = [
"set firewall ipv6-name INBOUND rule 101",
@@ -602,14 +603,14 @@ class TestVyosFirewallRulesModule(TestVyosModule):
number="101",
protocol="icmp",
icmp=dict(type_name="port-unreachable"),
- )
+ ),
],
),
],
- )
+ ),
],
state="merged",
- )
+ ),
)
commands = [
"set firewall ipv6-name INBOUND rule 101 icmpv6 type port-unreachable",
@@ -632,14 +633,14 @@ class TestVyosFirewallRulesModule(TestVyosModule):
number="101",
protocol="icmp",
icmp=dict(type=1, code=1),
- )
+ ),
],
),
],
- )
+ ),
],
state="merged",
- )
+ ),
)
commands = [
"set firewall name INBOUND rule 101 icmp type 1",
@@ -663,14 +664,14 @@ class TestVyosFirewallRulesModule(TestVyosModule):
number="101",
protocol="icmp",
icmp=dict(type_name="echo-request"),
- )
+ ),
],
),
],
- )
+ ),
],
state="merged",
- )
+ ),
)
commands = [
"set firewall name INBOUND rule 101 icmp type-name echo-request",
@@ -684,7 +685,7 @@ class TestVyosFirewallRulesModule(TestVyosModule):
dict(
config=[dict(afi="ipv4", rule_sets=[dict(name="V4-INGRESS")])],
state="deleted",
- )
+ ),
)
commands = ["delete firewall name V4-INGRESS"]
self.execute_module(changed=True, commands=commands)
@@ -697,7 +698,7 @@ class TestVyosFirewallRulesModule(TestVyosModule):
dict(afi="ipv6", rule_sets=[dict(name="V6-INGRESS")]),
],
state="deleted",
- )
+ ),
)
commands = [
"delete firewall name V4-INGRESS",
@@ -718,7 +719,7 @@ class TestVyosFirewallRulesModule(TestVyosModule):
dict(afi="ipv6", rule_sets=[dict(name="V6-ING")]),
],
state="deleted",
- )
+ ),
)
self.execute_module(changed=False, commands=[])
@@ -771,14 +772,14 @@ class TestVyosFirewallRulesModule(TestVyosModule):
dict(
icmp=dict(type_name="echo-request"),
number=20,
- )
+ ),
],
),
],
),
],
state="replaced",
- )
+ ),
)
commands = [
"delete firewall name V4-INGRESS rule 101 disable",
@@ -836,14 +837,14 @@ class TestVyosFirewallRulesModule(TestVyosModule):
dict(
icmp=dict(type_name="echo-request"),
number=20,
- )
+ ),
],
),
],
),
],
state="replaced",
- )
+ ),
)
commands = [
"delete firewall name V4-INGRESS enable-default-log",
@@ -871,7 +872,7 @@ class TestVyosFirewallRulesModule(TestVyosModule):
protocol="icmp",
fragment="match-frag",
disabled=True,
- )
+ ),
],
),
dict(
@@ -894,14 +895,14 @@ class TestVyosFirewallRulesModule(TestVyosModule):
dict(
icmp=dict(type_name="echo-request"),
number=20,
- )
+ ),
],
),
],
),
],
state="replaced",
- )
+ ),
)
self.execute_module(changed=False, commands=[])
@@ -933,7 +934,7 @@ class TestVyosFirewallRulesModule(TestVyosModule):
),
],
state="replaced",
- )
+ ),
)
self.execute_module(changed=False, commands=[])
@@ -958,7 +959,7 @@ class TestVyosFirewallRulesModule(TestVyosModule):
protocol="icmp",
fragment="match-frag",
disabled=True,
- )
+ ),
],
),
dict(
@@ -981,14 +982,14 @@ class TestVyosFirewallRulesModule(TestVyosModule):
dict(
icmp=dict(type_name="echo-request"),
number=20,
- )
+ ),
],
),
],
),
],
state="merged",
- )
+ ),
)
self.execute_module(changed=False, commands=[])
@@ -1019,7 +1020,7 @@ class TestVyosFirewallRulesModule(TestVyosModule):
address_group="IN-ADDR-GROUP",
network_group="IN-NET-GROUP",
port_group="IN-PORT-GROUP",
- )
+ ),
),
),
dict(
@@ -1050,7 +1051,7 @@ class TestVyosFirewallRulesModule(TestVyosModule):
),
],
state="overridden",
- )
+ ),
)
commands = [
"delete firewall ipv6-name V6-INGRESS",
@@ -1103,7 +1104,7 @@ class TestVyosFirewallRulesModule(TestVyosModule):
protocol="icmp",
fragment="match-frag",
disabled=True,
- )
+ ),
],
),
dict(
@@ -1126,14 +1127,14 @@ class TestVyosFirewallRulesModule(TestVyosModule):
dict(
icmp=dict(type_name="echo-request"),
number=20,
- )
+ ),
],
),
],
),
],
state="overridden",
- )
+ ),
)
self.execute_module(changed=False, commands=[])
@@ -1159,14 +1160,14 @@ class TestVyosFirewallRulesModule(TestVyosModule):
protocol="icmp",
disabled=True,
icmp=dict(type_name="echo-request"),
- )
+ ),
],
),
],
- )
+ ),
],
state="merged",
- )
+ ),
)
commands = [
"set firewall ipv6-name INBOUND default-action 'accept'",
diff --git a/tests/unit/modules/network/vyos/test_vyos_hostname.py b/tests/unit/modules/network/vyos/test_vyos_hostname.py
index c7edc26..a056f6b 100644
--- a/tests/unit/modules/network/vyos/test_vyos_hostname.py
+++ b/tests/unit/modules/network/vyos/test_vyos_hostname.py
@@ -18,6 +18,7 @@
# Make coding more python3-ish
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
from unittest.mock import patch
@@ -35,17 +36,17 @@ class TestVyosHostnameModule(TestVyosModule):
super(TestVyosHostnameModule, self).setUp()
self.mock_get_resource_connection_config = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection"
+ "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.mock_get_resource_connection_facts = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection"
+ "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.mock_execute_show_command = patch(
- "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.hostname.hostname.HostnameFacts.get_config"
+ "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.hostname.hostname.HostnameFacts.get_config",
)
self.execute_show_command = self.mock_execute_show_command.start()
diff --git a/tests/unit/modules/network/vyos/test_vyos_interfaces.py b/tests/unit/modules/network/vyos/test_vyos_interfaces.py
index 06bbefa..affb4f8 100644
--- a/tests/unit/modules/network/vyos/test_vyos_interfaces.py
+++ b/tests/unit/modules/network/vyos/test_vyos_interfaces.py
@@ -18,6 +18,7 @@
# Make coding more python3-ish
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
from unittest.mock import patch
@@ -34,28 +35,28 @@ class TestVyosFirewallInterfacesModule(TestVyosModule):
def setUp(self):
super(TestVyosFirewallInterfacesModule, self).setUp()
self.mock_get_config = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config"
+ "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config",
)
self.get_config = self.mock_get_config.start()
self.mock_load_config = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config"
+ "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config",
)
self.load_config = self.mock_load_config.start()
self.mock_get_resource_connection_config = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection"
+ "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.mock_get_resource_connection_facts = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection"
+ "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.mock_execute_show_command = patch(
"ansible_collections.vyos.vyos.plugins.module_utils.network.vyos."
- "facts.interfaces.interfaces.InterfacesFacts.get_device_data"
+ "facts.interfaces.interfaces.InterfacesFacts.get_device_data",
)
self.execute_show_command = self.mock_execute_show_command.start()
@@ -82,7 +83,7 @@ class TestVyosFirewallInterfacesModule(TestVyosModule):
dict(name="wg01", description="wg - 1", enabled=True),
],
state="merged",
- )
+ ),
)
commands = [
@@ -103,7 +104,7 @@ class TestVyosFirewallInterfacesModule(TestVyosModule):
),
],
state="merged",
- )
+ ),
)
self.execute_module(changed=False, commands=[])
@@ -122,7 +123,7 @@ class TestVyosFirewallInterfacesModule(TestVyosModule):
dict(name="eth1", description="Configured by Ansible"),
],
state="merged",
- )
+ ),
)
commands = [
@@ -147,7 +148,7 @@ class TestVyosFirewallInterfacesModule(TestVyosModule):
dict(name="eth1", description="Configured by Ansible"),
],
state="replaced",
- )
+ ),
)
commands = [
@@ -172,7 +173,7 @@ class TestVyosFirewallInterfacesModule(TestVyosModule):
dict(name="eth1", description="Configured by Ansible"),
],
state="overridden",
- )
+ ),
)
commands = [
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 209844e..872769e 100644
--- a/tests/unit/modules/network/vyos/test_vyos_logging_global.py
+++ b/tests/unit/modules/network/vyos/test_vyos_logging_global.py
@@ -5,6 +5,7 @@
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
from textwrap import dedent
@@ -23,17 +24,17 @@ class TestVyosLoggingGlobalModule(TestVyosModule):
super(TestVyosLoggingGlobalModule, self).setUp()
self.mock_get_resource_connection_config = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection"
+ "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.mock_get_resource_connection_facts = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection"
+ "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.mock_execute_show_command = patch(
- "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.logging_global.logging_global.Logging_globalFacts.get_logging_data"
+ "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.logging_global.logging_global.Logging_globalFacts.get_logging_data",
)
self.execute_show_command = self.mock_execute_show_command.start()
@@ -68,7 +69,7 @@ class TestVyosLoggingGlobalModule(TestVyosModule):
set system syslog user paul facility local7 level 'err'
set system syslog user vyos facility local6 level 'alert'
set system syslog user vyos facility local7 level 'debug'
- """
+ """,
)
playbook = dict(
config=dict(
@@ -77,7 +78,7 @@ class TestVyosLoggingGlobalModule(TestVyosModule):
dict(facility="all"),
dict(facility="local7", severity="err"),
dict(facility="news", severity="debug"),
- ]
+ ],
),
files=[
dict(path="xyz"),
@@ -127,7 +128,7 @@ class TestVyosLoggingGlobalModule(TestVyosModule):
dict(facility="local7", severity="debug"),
],
),
- )
+ ),
)
compare_cmds = []
playbook["state"] = "merged"
@@ -140,7 +141,7 @@ class TestVyosLoggingGlobalModule(TestVyosModule):
def test_vyos_logging_global_merged(self):
self.execute_show_command.return_value = dedent(
"""\
- """
+ """,
)
playbook = dict(
config=dict(
@@ -149,7 +150,7 @@ class TestVyosLoggingGlobalModule(TestVyosModule):
dict(facility="all"),
dict(facility="local7", severity="err"),
dict(facility="news", severity="debug"),
- ]
+ ],
),
files=[
dict(path="xyz"),
@@ -199,7 +200,7 @@ class TestVyosLoggingGlobalModule(TestVyosModule):
dict(facility="local7", severity="debug"),
],
),
- )
+ ),
)
compare_cmds = [
"set system syslog user paul facility local7 level err",
@@ -254,7 +255,7 @@ class TestVyosLoggingGlobalModule(TestVyosModule):
set system syslog user paul facility local7 level 'err'
set system syslog user vyos facility local6 level 'alert'
set system syslog user vyos facility local7 level 'debug'
- """
+ """,
)
playbook = dict(config=dict())
compare_cmds = ["delete system syslog"]
@@ -291,7 +292,7 @@ class TestVyosLoggingGlobalModule(TestVyosModule):
set system syslog user paul facility local7 level 'err'
set system syslog user vyos facility local6 level 'alert'
set system syslog user vyos facility local7 level 'debug'
- """
+ """,
)
playbook = dict(
config=dict(
@@ -304,9 +305,9 @@ class TestVyosLoggingGlobalModule(TestVyosModule):
dict(facility="local6", severity="err"),
dict(facility="local7", severity="emerg"),
],
- )
+ ),
],
- )
+ ),
)
compare_cmds = [
"delete system syslog console facility all",
@@ -344,7 +345,7 @@ class TestVyosLoggingGlobalModule(TestVyosModule):
self.execute_show_command.return_value = dedent(
"""\
set system syslog console facility local6
- """
+ """,
)
playbook = dict(config=dict(console=dict(facilities=[dict(facility="local6")])))
compare_cmds = []
@@ -359,7 +360,7 @@ class TestVyosLoggingGlobalModule(TestVyosModule):
"""\
set system syslog console
set system syslog global
- """
+ """,
)
playbook = dict(
config=dict(
@@ -372,9 +373,9 @@ class TestVyosLoggingGlobalModule(TestVyosModule):
dict(facility="local6", severity="err"),
dict(facility="local7", severity="emerg"),
],
- )
+ ),
],
- )
+ ),
)
compare_cmds = [
"set system syslog console facility local7 level emerg",
@@ -397,13 +398,13 @@ class TestVyosLoggingGlobalModule(TestVyosModule):
dict(
hostname="10.0.2.16",
facilities=[dict(facility="local6")],
- )
+ ),
],
users=[
dict(username="vyos"),
dict(username="paul", facilities=[dict(facility="local7")]),
],
- )
+ ),
)
compare_cmds = [
"set system syslog console facility all",
@@ -424,10 +425,10 @@ class TestVyosLoggingGlobalModule(TestVyosModule):
"""\
set system syslog console facility all
set system syslog file xyz
- """
+ """,
),
state="parsed",
- )
+ ),
)
parsed = dict(
console=dict(facilities=[dict(facility="all")]),
@@ -441,7 +442,7 @@ class TestVyosLoggingGlobalModule(TestVyosModule):
self.execute_show_command.return_value = dedent(
"""\
set system syslog console facility all
- """
+ """,
)
set_module_args(dict(state="gathered"))
gathered = dict(console=dict(facilities=[dict(facility="all")]))
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 37c851d..6609c2f 100644
--- a/tests/unit/modules/network/vyos/test_vyos_ntp_global.py
+++ b/tests/unit/modules/network/vyos/test_vyos_ntp_global.py
@@ -18,6 +18,7 @@
# Make coding more python3-ish
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
from unittest.mock import patch
@@ -35,17 +36,17 @@ class TestVyosNTPModule(TestVyosModule):
super(TestVyosNTPModule, self).setUp()
self.mock_get_resource_connection_config = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection"
+ "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.mock_get_resource_connection_facts = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection"
+ "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.mock_execute_show_command = patch(
- "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.ntp_global.ntp_global.Ntp_globalFacts.get_config"
+ "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.ntp_global.ntp_global.Ntp_globalFacts.get_config",
)
self.execute_show_command = self.mock_execute_show_command.start()
@@ -81,7 +82,7 @@ class TestVyosNTPModule(TestVyosModule):
],
),
state="merged",
- )
+ ),
)
self.execute_module(changed=False, commands=[])
@@ -105,7 +106,7 @@ class TestVyosNTPModule(TestVyosModule):
],
),
state="merged",
- )
+ ),
)
commands = [
@@ -146,7 +147,7 @@ class TestVyosNTPModule(TestVyosModule):
],
),
state="replaced",
- )
+ ),
)
commands = [
"delete system ntp allow-clients address 10.1.1.0/24",
@@ -183,7 +184,7 @@ class TestVyosNTPModule(TestVyosModule):
],
),
state="replaced",
- )
+ ),
)
self.execute_module(changed=False, commands=[])
@@ -202,7 +203,7 @@ class TestVyosNTPModule(TestVyosModule):
],
),
state="overridden",
- )
+ ),
)
commands = [
"delete system ntp allow-clients address 10.1.1.0/24",
@@ -234,7 +235,7 @@ class TestVyosNTPModule(TestVyosModule):
],
),
state="overridden",
- )
+ ),
)
self.execute_module(changed=False, commands=[])
@@ -253,7 +254,7 @@ class TestVyosNTPModule(TestVyosModule):
],
),
state="rendered",
- )
+ ),
)
rendered_commands = [
"set system ntp allow-clients address 10.7.7.0/24",
@@ -334,7 +335,7 @@ class TestVyosNTPModule(TestVyosModule):
],
),
state="deleted",
- )
+ ),
)
commands = [
"delete system ntp allow-clients",
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 248b98e..1d12a3c 100644
--- a/tests/unit/modules/network/vyos/test_vyos_ospf_interfaces.py
+++ b/tests/unit/modules/network/vyos/test_vyos_ospf_interfaces.py
@@ -18,6 +18,7 @@
# Make coding more python3-ish
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
from unittest.mock import patch
@@ -34,12 +35,12 @@ class TestVyosOspfInterfacesModule(TestVyosModule):
def setUp(self):
super(TestVyosOspfInterfacesModule, self).setUp()
self.mock_get_resource_connection_config = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection"
+ "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.mock_execute_show_command = patch(
- "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.ospf_interfaces.ospf_interfaces.Ospf_interfacesFacts.get_device_data"
+ "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.ospf_interfaces.ospf_interfaces.Ospf_interfacesFacts.get_device_data",
)
self.execute_show_command = self.mock_execute_show_command.start()
@@ -91,7 +92,7 @@ class TestVyosOspfInterfacesModule(TestVyosModule):
),
],
state="merged",
- )
+ ),
)
commands = [
"set interfaces bonding bond2 ip ospf transmit-delay 9",
@@ -124,7 +125,7 @@ class TestVyosOspfInterfacesModule(TestVyosModule):
],
),
],
- )
+ ),
)
self.execute_module(changed=False, commands=[])
@@ -149,7 +150,7 @@ class TestVyosOspfInterfacesModule(TestVyosModule):
],
),
],
- )
+ ),
)
commands = [
"set interfaces ethernet eth0 ipv6 ospfv3 cost 500",
@@ -185,7 +186,7 @@ class TestVyosOspfInterfacesModule(TestVyosModule):
),
],
state="replaced",
- )
+ ),
)
commands = [
"set interfaces bonding bond2 ip ospf transmit-delay 9",
@@ -220,7 +221,7 @@ class TestVyosOspfInterfacesModule(TestVyosModule):
),
],
state="replaced",
- )
+ ),
)
self.execute_module(changed=False, commands=[])
@@ -251,7 +252,7 @@ class TestVyosOspfInterfacesModule(TestVyosModule):
),
],
state="overridden",
- )
+ ),
)
commands = [
"set interfaces bonding bond2 ip ospf transmit-delay 9",
@@ -288,7 +289,7 @@ class TestVyosOspfInterfacesModule(TestVyosModule):
),
],
state="overridden",
- )
+ ),
)
self.execute_module(changed=False, commands=[])
@@ -301,7 +302,7 @@ class TestVyosOspfInterfacesModule(TestVyosModule):
),
],
state="deleted",
- )
+ ),
)
commands = ["delete interfaces ethernet eth0 ipv6 ospfv3"]
self.execute_module(changed=True, commands=commands)
@@ -315,7 +316,7 @@ class TestVyosOspfInterfacesModule(TestVyosModule):
),
],
state="deleted",
- )
+ ),
)
self.execute_module(changed=False, commands=[])
@@ -347,7 +348,7 @@ class TestVyosOspfInterfacesModule(TestVyosModule):
),
],
state="rendered",
- )
+ ),
)
commands = [
"set interfaces ethernet eth0 ip ospf cost 100",
@@ -389,7 +390,7 @@ class TestVyosOspfInterfacesModule(TestVyosModule):
"md5_key": {
"key": "1111111111232345",
"key_id": 10,
- }
+ },
},
"bandwidth": 70,
"transmit_delay": 45,
diff --git a/tests/unit/modules/network/vyos/test_vyos_ospfv2.py b/tests/unit/modules/network/vyos/test_vyos_ospfv2.py
index d2ddb40..ec4018e 100644
--- a/tests/unit/modules/network/vyos/test_vyos_ospfv2.py
+++ b/tests/unit/modules/network/vyos/test_vyos_ospfv2.py
@@ -18,6 +18,7 @@
# Make coding more python3-ish
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
from unittest.mock import patch
@@ -34,27 +35,27 @@ class TestVyosOspfv2Module(TestVyosModule):
def setUp(self):
super(TestVyosOspfv2Module, self).setUp()
self.mock_get_config = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config"
+ "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config",
)
self.get_config = self.mock_get_config.start()
self.mock_load_config = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config"
+ "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config",
)
self.load_config = self.mock_load_config.start()
self.mock_get_resource_connection_config = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection"
+ "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.mock_get_resource_connection_facts = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection"
+ "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.mock_execute_show_command = patch(
- "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.ospfv2.ospfv2.Ospfv2Facts.get_device_data"
+ "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.ospfv2.ospfv2.Ospfv2Facts.get_device_data",
)
self.execute_show_command = self.mock_execute_show_command.start()
@@ -103,7 +104,7 @@ class TestVyosOspfv2Module(TestVyosModule):
],
),
state="merged",
- )
+ ),
)
commands = [
"set protocols ospf mpls-te enable",
@@ -147,7 +148,7 @@ class TestVyosOspfv2Module(TestVyosModule):
],
),
state="merged",
- )
+ ),
)
self.execute_module(changed=False, commands=[])
@@ -177,7 +178,7 @@ class TestVyosOspfv2Module(TestVyosModule):
],
),
state="merged",
- )
+ ),
)
commands = [
"delete protocols ospf area 14 area-type stub",
@@ -212,7 +213,7 @@ class TestVyosOspfv2Module(TestVyosModule):
],
),
state="replaced",
- )
+ ),
)
commands = [
"set protocols ospf mpls-te enable",
@@ -255,7 +256,7 @@ class TestVyosOspfv2Module(TestVyosModule):
],
),
state="replaced",
- )
+ ),
)
self.execute_module(changed=False, commands=[])
@@ -346,7 +347,7 @@ set protocols ospf redistribute bgp metric-type '2'"""
"metric": 10,
"metric_type": 2,
"route_map": "ingress",
- }
+ },
},
"log_adjacency_changes": "detail",
"max_metric": {
@@ -354,7 +355,7 @@ set protocols ospf redistribute bgp metric-type '2'"""
"administrative": True,
"on_shutdown": 10,
"on_startup": 10,
- }
+ },
},
"mpls_te": {"enabled": True, "router_address": "192.0.11.11"},
"neighbor": [
@@ -362,7 +363,7 @@ set protocols ospf redistribute bgp metric-type '2'"""
"neighbor_id": "192.0.11.12",
"poll_interval": 10,
"priority": 2,
- }
+ },
],
"parameters": {
"abr_type": "cisco",
@@ -401,7 +402,7 @@ set protocols ospf redistribute bgp metric-type '2'"""
],
),
state="rendered",
- )
+ ),
)
commands = [
"set protocols ospf mpls-te enable",
diff --git a/tests/unit/modules/network/vyos/test_vyos_ospfv3.py b/tests/unit/modules/network/vyos/test_vyos_ospfv3.py
index 0002451..1cf0260 100644
--- a/tests/unit/modules/network/vyos/test_vyos_ospfv3.py
+++ b/tests/unit/modules/network/vyos/test_vyos_ospfv3.py
@@ -18,6 +18,7 @@
# Make coding more python3-ish
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
from unittest.mock import patch
@@ -34,27 +35,27 @@ class TestVyosOspfv3Module(TestVyosModule):
def setUp(self):
super(TestVyosOspfv3Module, self).setUp()
self.mock_get_config = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config"
+ "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config",
)
self.get_config = self.mock_get_config.start()
self.mock_load_config = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config"
+ "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config",
)
self.load_config = self.mock_load_config.start()
self.mock_get_resource_connection_config = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection"
+ "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.mock_get_resource_connection_facts = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection"
+ "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.mock_execute_show_command = patch(
- "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.ospfv3.ospfv3.Ospfv3Facts.get_device_data"
+ "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.ospfv3.ospfv3.Ospfv3Facts.get_device_data",
)
self.execute_show_command = self.mock_execute_show_command.start()
@@ -101,7 +102,7 @@ class TestVyosOspfv3Module(TestVyosModule):
],
),
state="merged",
- )
+ ),
)
commands = [
"set protocols ospfv3 redistribute bgp",
@@ -139,7 +140,7 @@ class TestVyosOspfv3Module(TestVyosModule):
],
),
state="merged",
- )
+ ),
)
self.execute_module(changed=False, commands=[])
@@ -170,7 +171,7 @@ class TestVyosOspfv3Module(TestVyosModule):
],
),
state="merged",
- )
+ ),
)
commands = [
"set protocols ospfv3 redistribute bgp",
@@ -203,7 +204,7 @@ class TestVyosOspfv3Module(TestVyosModule):
],
),
state="replaced",
- )
+ ),
)
commands = [
"set protocols ospfv3 redistribute bgp",
@@ -238,7 +239,7 @@ class TestVyosOspfv3Module(TestVyosModule):
],
),
state="replaced",
- )
+ ),
)
self.execute_module(changed=False, commands=[])
@@ -321,7 +322,7 @@ set protocols ospfv3 redistribute 'bgp'"""
],
),
state="rendered",
- )
+ ),
)
commands = [
"set protocols ospfv3 redistribute bgp",
diff --git a/tests/unit/modules/network/vyos/test_vyos_ping.py b/tests/unit/modules/network/vyos/test_vyos_ping.py
index 25bb6cf..2821696 100644
--- a/tests/unit/modules/network/vyos/test_vyos_ping.py
+++ b/tests/unit/modules/network/vyos/test_vyos_ping.py
@@ -18,6 +18,7 @@
# Make coding more python3-ish
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
from unittest.mock import patch
@@ -34,7 +35,7 @@ class TestVyosPingModule(TestVyosModule):
def setUp(self):
super(TestVyosPingModule, self).setUp()
self.mock_run_commands = patch(
- "ansible_collections.vyos.vyos.plugins.modules.vyos_ping.run_commands"
+ "ansible_collections.vyos.vyos.plugins.modules.vyos_ping.run_commands",
)
self.run_commands = self.mock_run_commands.start()
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 5c488ec..3da58f7 100644
--- a/tests/unit/modules/network/vyos/test_vyos_prefix_lists.py
+++ b/tests/unit/modules/network/vyos/test_vyos_prefix_lists.py
@@ -18,6 +18,7 @@
# Make coding more python3-ish
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
from textwrap import dedent
@@ -47,12 +48,12 @@ class TestVyosPrefixListsModule(TestVyosModule):
super(TestVyosPrefixListsModule, self).setUp()
self.mock_get_resource_connection = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection"
+ "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.mock_get_config = patch(
- "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.prefix_lists.prefix_lists.Prefix_listsFacts.get_config"
+ "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.prefix_lists.prefix_lists.Prefix_listsFacts.get_config",
)
self.get_config = self.mock_get_config.start()
@@ -65,7 +66,7 @@ class TestVyosPrefixListsModule(TestVyosModule):
def test_vyos_prefix_lists_linear_merged(self):
self.get_config.return_value = dedent(
"""\
- """
+ """,
)
set_module_args(
dict(
@@ -151,7 +152,7 @@ class TestVyosPrefixListsModule(TestVyosModule):
),
],
state="merged",
- )
+ ),
)
commands = [
"set policy prefix-list plist1",
@@ -236,7 +237,7 @@ class TestVyosPrefixListsModule(TestVyosModule):
set policy prefix-list6 plist4 rule 50
set policy prefix-list6 plist4 rule 50 action 'deny'
set policy prefix-list6 plist4 rule 50 prefix '2001:db8:4000::/36'
- """
+ """,
)
set_module_args(
dict(
@@ -322,7 +323,7 @@ class TestVyosPrefixListsModule(TestVyosModule):
),
],
state="merged",
- )
+ ),
)
result = self.execute_module(changed=False)
self.assertEqual(result["commands"], [])
@@ -368,7 +369,7 @@ class TestVyosPrefixListsModule(TestVyosModule):
set policy prefix-list6 plist4 rule 50
set policy prefix-list6 plist4 rule 50 action 'deny'
set policy prefix-list6 plist4 rule 50 prefix '2001:db8:4000::/36'
- """
+ """,
)
set_module_args(
dict(
@@ -392,12 +393,12 @@ class TestVyosPrefixListsModule(TestVyosModule):
prefix="72.168.2.0/24",
),
],
- )
+ ),
],
- )
+ ),
],
state="replaced",
- )
+ ),
)
commands = [
"delete policy prefix-list plist1 rule 10 description 'Test rule 10'",
@@ -447,7 +448,7 @@ class TestVyosPrefixListsModule(TestVyosModule):
set policy prefix-list6 plist4 rule 50
set policy prefix-list6 plist4 rule 50 action 'deny'
set policy prefix-list6 plist4 rule 50 prefix '2001:db8:4000::/36'
- """
+ """,
)
set_module_args(
dict(
@@ -462,14 +463,14 @@ class TestVyosPrefixListsModule(TestVyosModule):
sequence=10,
action="permit",
prefix="82.168.10.0/26",
- )
+ ),
],
- )
+ ),
],
- )
+ ),
],
state="replaced",
- )
+ ),
)
commands = [
"delete policy prefix-list plist1 description 'Test plist1'",
@@ -521,7 +522,7 @@ class TestVyosPrefixListsModule(TestVyosModule):
set policy prefix-list6 plist4 rule 50
set policy prefix-list6 plist4 rule 50 action 'deny'
set policy prefix-list6 plist4 rule 50 prefix '2001:db8:4000::/36'
- """
+ """,
)
set_module_args(
dict(
@@ -536,14 +537,14 @@ class TestVyosPrefixListsModule(TestVyosModule):
sequence=10,
action="deny",
prefix="102.168.10.0/26",
- )
+ ),
],
- )
+ ),
],
- )
+ ),
],
state="overridden",
- )
+ ),
)
commands = [
"delete policy prefix-list plist1 description 'Test plist1'",
@@ -599,7 +600,7 @@ class TestVyosPrefixListsModule(TestVyosModule):
set policy prefix-list6 plist4 rule 50
set policy prefix-list6 plist4 rule 50 action 'deny'
set policy prefix-list6 plist4 rule 50 prefix '2001:db8:4000::/36'
- """
+ """,
)
set_module_args(
dict(
@@ -614,14 +615,14 @@ class TestVyosPrefixListsModule(TestVyosModule):
sequence=50,
action="permit",
prefix="102.168.10.0/26",
- )
+ ),
],
- )
+ ),
],
- )
+ ),
],
state="overridden",
- )
+ ),
)
commands = [
"set policy prefix-list plist5",
@@ -677,7 +678,7 @@ class TestVyosPrefixListsModule(TestVyosModule):
set policy prefix-list6 plist4 rule 50
set policy prefix-list6 plist4 rule 50 action 'deny'
set policy prefix-list6 plist4 rule 50 prefix '2001:db8:4000::/36'
- """
+ """,
)
set_module_args(dict(state="deleted"))
commands = [
@@ -730,7 +731,7 @@ class TestVyosPrefixListsModule(TestVyosModule):
set policy prefix-list6 plist4 rule 50
set policy prefix-list6 plist4 rule 50 action 'deny'
set policy prefix-list6 plist4 rule 50 prefix '2001:db8:4000::/36'
- """
+ """,
)
set_module_args(dict(config=[dict(afi="ipv4")], state="deleted"))
commands = [
@@ -781,13 +782,13 @@ class TestVyosPrefixListsModule(TestVyosModule):
set policy prefix-list6 plist4 rule 50
set policy prefix-list6 plist4 rule 50 action 'deny'
set policy prefix-list6 plist4 rule 50 prefix '2001:db8:4000::/36'
- """
+ """,
)
set_module_args(
dict(
config=[dict(afi="ipv6", prefix_lists=[dict(name="plist3")])],
state="deleted",
- )
+ ),
)
commands = ["delete policy prefix-list6 plist3"]
result = self.execute_module(changed=True)
@@ -834,7 +835,7 @@ class TestVyosPrefixListsModule(TestVyosModule):
set policy prefix-list6 plist4 rule 50
set policy prefix-list6 plist4 rule 50 action 'deny'
set policy prefix-list6 plist4 rule 50 prefix '2001:db8:4000::/36'
- """
+ """,
)
set_module_args(
dict(
@@ -843,7 +844,7 @@ class TestVyosPrefixListsModule(TestVyosModule):
dict(afi="ipv6", prefix_lists=[dict(name="plist3")]),
],
state="deleted",
- )
+ ),
)
commands = [
"delete policy prefix-list plist2",
@@ -893,7 +894,7 @@ class TestVyosPrefixListsModule(TestVyosModule):
set policy prefix-list6 plist4 rule 50
set policy prefix-list6 plist4 rule 50 action 'deny'
set policy prefix-list6 plist4 rule 50 prefix '2001:db8:4000::/36'
- """
+ """,
)
set_module_args(dict(running_config=cfg, state="parsed"))
parsed = [
@@ -1066,7 +1067,7 @@ class TestVyosPrefixListsModule(TestVyosModule):
),
],
state="rendered",
- )
+ ),
)
rendered = [
"set policy prefix-list plist1",
@@ -1151,7 +1152,7 @@ class TestVyosPrefixListsModule(TestVyosModule):
set policy prefix-list6 plist4 rule 50
set policy prefix-list6 plist4 rule 50 action 'deny'
set policy prefix-list6 plist4 rule 50 prefix '2001:db8:4000::/36'
- """
+ """,
)
set_module_args(dict(state="gathered"))
gathered = [
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 adac6c3..ce13dcf 100644
--- a/tests/unit/modules/network/vyos/test_vyos_route_maps.py
+++ b/tests/unit/modules/network/vyos/test_vyos_route_maps.py
@@ -18,6 +18,7 @@
# Make coding more python3-ish
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
from unittest.mock import patch
@@ -35,17 +36,17 @@ class TestVyosRouteMapsModule(TestVyosModule):
super(TestVyosRouteMapsModule, self).setUp()
self.mock_get_resource_connection_config = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection"
+ "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.mock_get_resource_connection_facts = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection"
+ "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.mock_execute_show_command = patch(
- "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.route_maps.route_maps.Route_mapsFacts.get_config"
+ "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.route_maps.route_maps.Route_mapsFacts.get_config",
)
self.execute_show_command = self.mock_execute_show_command.start()
@@ -100,12 +101,12 @@ class TestVyosRouteMapsModule(TestVyosModule):
tag=5,
weight=4,
),
- )
+ ),
],
- )
+ ),
],
state="merged",
- )
+ ),
)
self.execute_module(changed=False, commands=[])
@@ -144,12 +145,12 @@ class TestVyosRouteMapsModule(TestVyosModule):
tag=4,
weight=4,
),
- )
+ ),
],
- )
+ ),
],
state="merged",
- )
+ ),
)
commands = [
"set policy route-map test2 rule 1 action permit",
@@ -209,12 +210,12 @@ class TestVyosRouteMapsModule(TestVyosModule):
tag=4,
weight=4,
),
- )
+ ),
],
),
],
state="replaced",
- )
+ ),
)
commands = [
"delete policy route-map test3 rule 1 match interface eth2",
@@ -261,12 +262,12 @@ class TestVyosRouteMapsModule(TestVyosModule):
tag=5,
weight=4,
),
- )
+ ),
],
),
],
state="replaced",
- )
+ ),
)
self.execute_module(changed=False, commands=[])
@@ -299,12 +300,12 @@ class TestVyosRouteMapsModule(TestVyosModule):
tag=4,
weight=4,
),
- )
+ ),
],
- )
+ ),
],
state="overridden",
- )
+ ),
)
commands = [
"delete policy route-map test3",
@@ -361,12 +362,12 @@ class TestVyosRouteMapsModule(TestVyosModule):
tag=5,
weight=4,
),
- )
+ ),
],
),
],
state="overridden",
- )
+ ),
)
self.execute_module(changed=False, commands=[])
@@ -404,7 +405,7 @@ class TestVyosRouteMapsModule(TestVyosModule):
tag=5,
weight=4,
),
- )
+ ),
],
),
dict(
@@ -425,7 +426,7 @@ class TestVyosRouteMapsModule(TestVyosModule):
),
],
state="rendered",
- )
+ ),
)
rendered_cmds = [
"set policy route-map test3 rule 1 action permit",
@@ -504,7 +505,7 @@ class TestVyosRouteMapsModule(TestVyosModule):
"tag": "5",
"weight": "4",
},
- }
+ },
],
"route_map": "test3",
},
@@ -544,7 +545,7 @@ class TestVyosRouteMapsModule(TestVyosModule):
"tag": "5",
"weight": "4",
},
- }
+ },
],
"route_map": "test3",
},
@@ -572,12 +573,12 @@ class TestVyosRouteMapsModule(TestVyosModule):
tag=5,
weight=4,
),
- )
+ ),
],
),
],
state="deleted",
- )
+ ),
)
commands = ["delete policy route-map test3"]
self.execute_module(changed=True, commands=commands)
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 b6d61b1..4314465 100644
--- a/tests/unit/modules/network/vyos/test_vyos_snmp_server.py
+++ b/tests/unit/modules/network/vyos/test_vyos_snmp_server.py
@@ -18,6 +18,7 @@
# Make coding more python3-ish
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
from unittest.mock import patch
@@ -35,17 +36,17 @@ class TestVyosSnmpServerModule(TestVyosModule):
super(TestVyosSnmpServerModule, self).setUp()
self.mock_get_resource_connection_config = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.rm_base.resource_module_base.get_resource_connection"
+ "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.mock_get_resource_connection_facts = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection"
+ "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.mock_execute_show_command = patch(
- "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.snmp_server.snmp_server.Snmp_serverFacts.get_config"
+ "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.snmp_server.snmp_server.Snmp_serverFacts.get_config",
)
self.execute_show_command = self.mock_execute_show_command.start()
@@ -74,7 +75,7 @@ class TestVyosSnmpServerModule(TestVyosModule):
dict(
name="bridges",
networks=["12.1.1.0/24", "1.1.1.0/24"],
- )
+ ),
],
listen_addresses=[
dict(address="100.1.2.1", port=33),
@@ -92,11 +93,11 @@ class TestVyosSnmpServerModule(TestVyosModule):
authentication=dict(type="sha", plaintext_key="opq1234567"),
privacy=dict(type="aes", plaintext_key="opq1234567"),
),
- ]
+ ],
),
),
state="merged",
- )
+ ),
)
self.execute_module(changed=False, commands=[])
@@ -108,7 +109,7 @@ class TestVyosSnmpServerModule(TestVyosModule):
dict(
name="bridges",
networks=["12.1.1.0/24", "1.1.1.0/24"],
- )
+ ),
],
listen_addresses=[
dict(address="100.1.2.1", port=33),
@@ -126,11 +127,11 @@ class TestVyosSnmpServerModule(TestVyosModule):
authentication=dict(type="sha", plaintext_key="opq1234567"),
privacy=dict(type="aes", plaintext_key="opq1234567"),
),
- ]
+ ],
),
),
state="replaced",
- )
+ ),
)
self.execute_module(changed=False, commands=[])
@@ -142,7 +143,7 @@ class TestVyosSnmpServerModule(TestVyosModule):
dict(
name="bridges",
networks=["12.1.1.0/24", "1.1.1.0/24"],
- )
+ ),
],
listen_addresses=[
dict(address="100.1.2.1", port=33),
@@ -160,11 +161,11 @@ class TestVyosSnmpServerModule(TestVyosModule):
authentication=dict(type="sha", plaintext_key="opq1234567"),
privacy=dict(type="aes", plaintext_key="opq1234567"),
),
- ]
+ ],
),
),
state="overridden",
- )
+ ),
)
self.execute_module(changed=False, commands=[])
@@ -193,7 +194,7 @@ class TestVyosSnmpServerModule(TestVyosModule):
mode="rw",
seclevel="priv",
view="view1",
- )
+ ),
],
trap_targets=[
dict(
@@ -205,7 +206,7 @@ class TestVyosSnmpServerModule(TestVyosModule):
),
),
state="merged",
- )
+ ),
)
commands = [
"set service snmp community routers client 1.1.1.0/24",
@@ -249,7 +250,7 @@ class TestVyosSnmpServerModule(TestVyosModule):
mode="rw",
seclevel="priv",
view="view1",
- )
+ ),
],
trap_targets=[
dict(
@@ -261,7 +262,7 @@ class TestVyosSnmpServerModule(TestVyosModule):
),
),
state="replaced",
- )
+ ),
)
commands = [
"set service snmp community routers client 1.1.1.0/24",
@@ -318,7 +319,7 @@ class TestVyosSnmpServerModule(TestVyosModule):
mode="rw",
seclevel="priv",
view="view1",
- )
+ ),
],
trap_targets=[
dict(
@@ -330,7 +331,7 @@ class TestVyosSnmpServerModule(TestVyosModule):
),
),
state="overridden",
- )
+ ),
)
commands = [
"set service snmp community routers client 1.1.1.0/24",
@@ -366,7 +367,7 @@ class TestVyosSnmpServerModule(TestVyosModule):
set_module_args(
dict(
state="deleted",
- )
+ ),
)
commands = ["delete service snmp"]
self.execute_module(changed=True, commands=commands)
@@ -396,7 +397,7 @@ class TestVyosSnmpServerModule(TestVyosModule):
mode="rw",
seclevel="priv",
view="view1",
- )
+ ),
],
trap_targets=[
dict(
@@ -408,7 +409,7 @@ class TestVyosSnmpServerModule(TestVyosModule):
),
),
state="rendered",
- )
+ ),
)
commands = [
"set service snmp community routers client 1.1.1.0/24",
@@ -471,7 +472,7 @@ class TestVyosSnmpServerModule(TestVyosModule):
"mode": "rw",
"seclevel": "priv",
"view": "view1",
- }
+ },
],
},
"trap_source": "1.1.1.1",
@@ -512,7 +513,7 @@ class TestVyosSnmpServerModule(TestVyosModule):
},
"user": "guest_user",
},
- ]
+ ],
},
}
self.assertEqual(gathered_list, result["gathered"])
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 96137bd..b38d979 100644
--- a/tests/unit/modules/network/vyos/test_vyos_static_routes.py
+++ b/tests/unit/modules/network/vyos/test_vyos_static_routes.py
@@ -18,6 +18,7 @@
# Make coding more python3-ish
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
from unittest.mock import patch
@@ -34,27 +35,27 @@ class TestVyosStaticRoutesModule(TestVyosModule):
def setUp(self):
super(TestVyosStaticRoutesModule, self).setUp()
self.mock_get_config = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config"
+ "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.get_config",
)
self.get_config = self.mock_get_config.start()
self.mock_load_config = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config"
+ "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network.Config.load_config",
)
self.load_config = self.mock_load_config.start()
self.mock_get_resource_connection_config = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base.get_resource_connection"
+ "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.mock_get_resource_connection_facts = patch(
- "ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts.get_resource_connection"
+ "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.mock_execute_show_command = patch(
- "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.static_routes.static_routes.Static_routesFacts.get_device_data"
+ "ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.facts.static_routes.static_routes.Static_routesFacts.get_device_data",
)
self.execute_show_command = self.mock_execute_show_command.start()
@@ -93,14 +94,14 @@ class TestVyosStaticRoutesModule(TestVyosModule):
interface="eth0",
),
],
- )
+ ),
],
- )
- ]
- )
+ ),
+ ],
+ ),
],
state="merged",
- )
+ ),
)
commands = [
"set protocols static route 192.0.2.48/28",
@@ -126,14 +127,14 @@ class TestVyosStaticRoutesModule(TestVyosModule):
dict(forward_router_address="192.0.2.9"),
dict(forward_router_address="192.0.2.10"),
],
- )
+ ),
],
- )
- ]
- )
+ ),
+ ],
+ ),
],
state="merged",
- )
+ ),
)
self.execute_module(changed=False, commands=[])
@@ -158,14 +159,14 @@ class TestVyosStaticRoutesModule(TestVyosModule):
admin_distance=10,
),
],
- )
+ ),
],
- )
- ]
- )
+ ),
+ ],
+ ),
],
state="replaced",
- )
+ ),
)
commands = [
"set protocols static route 192.0.2.48/28",
@@ -191,14 +192,14 @@ class TestVyosStaticRoutesModule(TestVyosModule):
dict(forward_router_address="192.0.2.9"),
dict(forward_router_address="192.0.2.10"),
],
- )
+ ),
],
- )
- ]
- )
+ ),
+ ],
+ ),
],
state="replaced",
- )
+ ),
)
self.execute_module(changed=False, commands=[])
@@ -218,14 +219,14 @@ class TestVyosStaticRoutesModule(TestVyosModule):
dict(forward_router_address="192.0.2.9"),
dict(forward_router_address="192.0.2.10"),
],
- )
+ ),
],
- )
- ]
- )
+ ),
+ ],
+ ),
],
state="overridden",
- )
+ ),
)
commands = [
"delete protocols static route 192.0.2.32/28",
@@ -250,14 +251,14 @@ class TestVyosStaticRoutesModule(TestVyosModule):
dict(forward_router_address="192.0.2.9"),
dict(forward_router_address="192.0.2.10"),
],
- )
+ ),
],
- )
- ]
- )
+ ),
+ ],
+ ),
],
state="overridden",
- )
+ ),
)
self.execute_module(changed=False, commands=[])
@@ -266,7 +267,7 @@ class TestVyosStaticRoutesModule(TestVyosModule):
dict(
config=[dict(address_families=[dict(afi="ipv4")])],
state="deleted",
- )
+ ),
)
commands = ["delete protocols static route"]
self.execute_module(changed=True, commands=commands)
diff --git a/tests/unit/modules/network/vyos/test_vyos_system.py b/tests/unit/modules/network/vyos/test_vyos_system.py
index 252172d..cf405ca 100644
--- a/tests/unit/modules/network/vyos/test_vyos_system.py
+++ b/tests/unit/modules/network/vyos/test_vyos_system.py
@@ -18,6 +18,7 @@
# Make coding more python3-ish
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
from unittest.mock import patch
@@ -35,12 +36,12 @@ class TestVyosSystemModule(TestVyosModule):
super(TestVyosSystemModule, self).setUp()
self.mock_get_config = patch(
- "ansible_collections.vyos.vyos.plugins.modules.vyos_system.get_config"
+ "ansible_collections.vyos.vyos.plugins.modules.vyos_system.get_config",
)
self.get_config = self.mock_get_config.start()
self.mock_load_config = patch(
- "ansible_collections.vyos.vyos.plugins.modules.vyos_system.load_config"
+ "ansible_collections.vyos.vyos.plugins.modules.vyos_system.load_config",
)
self.load_config = self.mock_load_config.start()
@@ -97,7 +98,7 @@ class TestVyosSystemModule(TestVyosModule):
host_name="router",
domain_name="example.com",
name_server=["8.8.8.8", "8.8.4.4"],
- )
+ ),
)
result = self.execute_module()
self.assertEqual([], result["commands"])
diff --git a/tests/unit/modules/network/vyos/test_vyos_user.py b/tests/unit/modules/network/vyos/test_vyos_user.py
index 2387296..7029720 100644
--- a/tests/unit/modules/network/vyos/test_vyos_user.py
+++ b/tests/unit/modules/network/vyos/test_vyos_user.py
@@ -18,6 +18,7 @@
# Make coding more python3-ish
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
from unittest.mock import patch
@@ -35,12 +36,12 @@ class TestVyosUserModule(TestVyosModule):
super(TestVyosUserModule, self).setUp()
self.mock_get_config = patch(
- "ansible_collections.vyos.vyos.plugins.modules.vyos_user.get_config"
+ "ansible_collections.vyos.vyos.plugins.modules.vyos_user.get_config",
)
self.get_config = self.mock_get_config.start()
self.mock_load_config = patch(
- "ansible_collections.vyos.vyos.plugins.modules.vyos_user.load_config"
+ "ansible_collections.vyos.vyos.plugins.modules.vyos_user.load_config",
)
self.load_config = self.mock_load_config.start()
@@ -87,7 +88,7 @@ class TestVyosUserModule(TestVyosModule):
[
"delete system login user ansible",
"delete system login user admin",
- ]
+ ],
),
)
@@ -97,7 +98,7 @@ class TestVyosUserModule(TestVyosModule):
name="test",
configured_password="test",
update_password="on_create",
- )
+ ),
)
result = self.execute_module(changed=True)
self.assertEqual(
@@ -111,7 +112,7 @@ class TestVyosUserModule(TestVyosModule):
name="ansible",
configured_password="test",
update_password="on_create",
- )
+ ),
)
self.execute_module()
@@ -121,7 +122,7 @@ class TestVyosUserModule(TestVyosModule):
name="ansible",
configured_password="test",
update_password="always",
- )
+ ),
)
result = self.execute_module(changed=True)
self.assertEqual(
diff --git a/tests/unit/modules/network/vyos/vyos_module.py b/tests/unit/modules/network/vyos/vyos_module.py
index b1bdc2e..60d94b5 100644
--- a/tests/unit/modules/network/vyos/vyos_module.py
+++ b/tests/unit/modules/network/vyos/vyos_module.py
@@ -18,6 +18,7 @@
# Make coding more python3-ish
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
import json
@@ -29,6 +30,7 @@ from ansible_collections.vyos.vyos.tests.unit.modules.utils import (
ModuleTestCase,
)
+
fixture_path = os.path.join(os.path.dirname(__file__), "fixtures")
fixture_data = {}
diff --git a/tests/unit/modules/utils.py b/tests/unit/modules/utils.py
index a7dd0b3..6489f13 100644
--- a/tests/unit/modules/utils.py
+++ b/tests/unit/modules/utils.py
@@ -1,8 +1,10 @@
from __future__ import absolute_import, division, print_function
+
__metaclass__ = type
import json
import unittest
+
from unittest.mock import patch
from ansible.module_utils import basic
@@ -41,7 +43,9 @@ def fail_json(*args, **kwargs):
class ModuleTestCase(unittest.TestCase):
def setUp(self):
self.mock_module = patch.multiple(
- basic.AnsibleModule, exit_json=exit_json, fail_json=fail_json
+ basic.AnsibleModule,
+ exit_json=exit_json,
+ fail_json=fail_json,
)
self.mock_module.start()
self.mock_sleep = patch("time.sleep")