summaryrefslogtreecommitdiffstats
path: root/ansible_collections/junipernetworks/junos/tests
diff options
context:
space:
mode:
Diffstat (limited to 'ansible_collections/junipernetworks/junos/tests')
-rw-r--r--ansible_collections/junipernetworks/junos/tests/config.yml3
-rw-r--r--ansible_collections/junipernetworks/junos/tests/integration/targets/junos_facts/tests/netconf/network_facts.yaml124
-rw-r--r--ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/rtt.yml12
-rw-r--r--ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/aliases0
-rw-r--r--ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/defaults/main.yaml2
-rw-r--r--ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/meta/main.yml3
-rw-r--r--ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/tasks/main.yaml3
-rw-r--r--ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/tasks/netconf.yaml21
-rw-r--r--ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/tests/netconf/basic.yaml407
-rw-r--r--ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/_reset_config.yaml6
-rw-r--r--ansible_collections/junipernetworks/junos/tests/integration/targets/prepare_junos_tests/tasks/main.yml20
-rw-r--r--ansible_collections/junipernetworks/junos/tests/integration/targets/prepare_junos_tests/tasks/prepare.yml18
-rw-r--r--ansible_collections/junipernetworks/junos/tests/sanity/ignore-2.11.txt1
-rw-r--r--ansible_collections/junipernetworks/junos/tests/sanity/ignore-2.12.txt1
-rw-r--r--ansible_collections/junipernetworks/junos/tests/sanity/ignore-2.13.txt1
-rw-r--r--ansible_collections/junipernetworks/junos/tests/sanity/ignore-2.18.txt (renamed from ansible_collections/junipernetworks/junos/tests/sanity/ignore-2.10.txt)0
-rw-r--r--ansible_collections/junipernetworks/junos/tests/sanity/ignore-2.9.txt5
-rw-r--r--ansible_collections/junipernetworks/junos/tests/unit/compat/__init__.py0
-rw-r--r--ansible_collections/junipernetworks/junos/tests/unit/compat/mock.py130
-rw-r--r--ansible_collections/junipernetworks/junos/tests/unit/compat/unittest.py41
-rw-r--r--ansible_collections/junipernetworks/junos/tests/unit/mock/path.py4
-rw-r--r--ansible_collections/junipernetworks/junos/tests/unit/mock/procenv.py5
-rw-r--r--ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_bgp_address_family.py3
-rw-r--r--ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_bgp_global.py3
-rw-r--r--ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_command.py3
-rw-r--r--ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_config.py3
-rw-r--r--ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_facts.py3
-rw-r--r--ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_hostname.py3
-rw-r--r--ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_interfaces.py3
-rw-r--r--ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_l2_interfaces.py3
-rw-r--r--ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_l3_interfaces.py3
-rw-r--r--ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_logging_global.py3
-rw-r--r--ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_netconf.py3
-rw-r--r--ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_ntp_global.py3
-rw-r--r--ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_ospf_interfaces.py3
-rw-r--r--ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_ospfv2.py13
-rw-r--r--ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_ospfv3.py3
-rw-r--r--ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_package.py3
-rw-r--r--ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_ping.py3
-rw-r--r--ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_prefix_lists.py3
-rw-r--r--ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_routing_instances.py3
-rw-r--r--ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_routing_options.py3
-rw-r--r--ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_rpc.py3
-rw-r--r--ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_scp.py3
-rw-r--r--ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_security_policies.py3
-rw-r--r--ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_security_policies_global.py3
-rw-r--r--ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_security_zones.py3
-rw-r--r--ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_snmp_server.py3
-rw-r--r--ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_vlans.py3
-rw-r--r--ansible_collections/junipernetworks/junos/tests/unit/modules/utils.py8
50 files changed, 222 insertions, 684 deletions
diff --git a/ansible_collections/junipernetworks/junos/tests/config.yml b/ansible_collections/junipernetworks/junos/tests/config.yml
new file mode 100644
index 000000000..c26ea5966
--- /dev/null
+++ b/ansible_collections/junipernetworks/junos/tests/config.yml
@@ -0,0 +1,3 @@
+---
+modules:
+ python_requires: ">=3.9"
diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_facts/tests/netconf/network_facts.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_facts/tests/netconf/network_facts.yaml
new file mode 100644
index 000000000..f0d08f310
--- /dev/null
+++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_facts/tests/netconf/network_facts.yaml
@@ -0,0 +1,124 @@
+---
+- ansible.builtin.debug:
+ msg="START cli_config/cli_basic.yaml on connection={{ ansible_connection
+ }}"
+
+- name: Reset acls
+ junipernetworks.junos.junos_acls:
+ state: deleted
+
+- name: Reset vlans
+ junipernetworks.junos.junos_vlans:
+ state: deleted
+
+- name: Reset lldp_global
+ junipernetworks.junos.junos_lldp_global:
+ state: deleted
+
+- name: Reset lldp_interfaces
+ junipernetworks.junos.junos_lldp_interfaces:
+ state: deleted
+
+- name: Reset logging_global
+ junipernetworks.junos.junos_logging_global:
+ state: deleted
+
+- name: Reset ntp_global
+ junipernetworks.junos.junos_ntp_global:
+ state: deleted
+
+- name: Reset ospf_interfaces
+ junipernetworks.junos.junos_ospf_interfaces:
+ state: deleted
+
+- name: Reset ospfv2
+ junipernetworks.junos.junos_ospfv2:
+ state: deleted
+
+- name: Reset ospfv3
+ junipernetworks.junos.junos_ospfv3:
+ state: deleted
+
+- name: Reset prefix_lists
+ junipernetworks.junos.junos_prefix_lists:
+ state: deleted
+
+- name: Reset routing_instances
+ junipernetworks.junos.junos_routing_instances:
+ state: deleted
+
+- name: Reset routing_options
+ junipernetworks.junos.junos_routing_options:
+ state: deleted
+
+- name: Reset security_policies
+ junipernetworks.junos.junos_security_policies:
+ state: deleted
+
+- name: Reset security_policies_global
+ junipernetworks.junos.junos_security_policies_global:
+ state: deleted
+
+- name: Reset security_zones
+ junipernetworks.junos.junos_security_zones:
+ state: deleted
+
+- name: Reset snmp_server
+ junipernetworks.junos.junos_snmp_server:
+ state: deleted
+
+- name: Reset static_routes
+ junipernetworks.junos.junos_static_routes:
+ state: deleted
+
+- name: Gather junipernetworks junos facts
+ junipernetworks.junos.junos_facts:
+ gather_subset: config
+ gather_network_resources:
+ - acls
+ - lldp_global
+ - lldp_interfaces
+ - logging_global
+ - ntp_global
+ - ospf_interfaces
+ - ospfv2
+ - ospfv3
+ - prefix_lists
+ - routing_instances
+ - routing_options
+ - security_policies
+ - security_policies_global
+ - security_zones
+ - snmp_server
+ - static_routes
+ - vlans
+ register: gather_resources
+
+- name: Display Facts
+ ansible.builtin.debug:
+ msg: "{{ gather_resources }}"
+
+- name: Assert that empty facts was generated
+ ansible.builtin.assert:
+ that:
+ - " gather_resources['ansible_facts']['ansible_network_resources']['acls'] == []"
+ - " gather_resources['ansible_facts']['ansible_network_resources']['lldp_global'] == {}"
+ - " gather_resources['ansible_facts']['ansible_network_resources']['lldp_interfaces'] == []"
+ - " gather_resources['ansible_facts']['ansible_network_resources']['logging_global'] == {}"
+ - " gather_resources['ansible_facts']['ansible_network_resources']['ntp_global'] == {}"
+ - " gather_resources['ansible_facts']['ansible_network_resources']['ospf_interfaces'] == []"
+ - " gather_resources['ansible_facts']['ansible_network_resources']['ospfv2'] == []"
+ - " gather_resources['ansible_facts']['ansible_network_resources']['ospfv3'] == []"
+ - " gather_resources['ansible_facts']['ansible_network_resources']['prefix_lists'] == []"
+ - " gather_resources['ansible_facts']['ansible_network_resources']['routing_instances'] == []"
+ - " gather_resources['ansible_facts']['ansible_network_resources']['routing_options'] == []"
+ - " gather_resources['ansible_facts']['ansible_network_resources']['security_policies'] == {}"
+ - " gather_resources['ansible_facts']['ansible_network_resources']['security_policies_global'] == {}"
+ - " gather_resources['ansible_facts']['ansible_network_resources']['security_zones'] == {}"
+ - " gather_resources['ansible_facts']['ansible_network_resources']['snmp_server'] == {}"
+ - " gather_resources['ansible_facts']['ansible_network_resources']['static_routes'] == []"
+ - " gather_resources['ansible_facts']['ansible_network_resources']['vlans'] == []"
+
+- ansible.builtin.debug:
+ msg="END cli_config/cli_basic.yaml on connection={{ ansible_connection
+ }}"
diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/rtt.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/rtt.yml
index 634727a67..f934983c9 100644
--- a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/rtt.yml
+++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_l2_interfaces/tests/netconf/rtt.yml
@@ -16,7 +16,6 @@
trunk:
allowed_vlans:
- vlan100
- native_vlan: "200"
state: merged
- name: Gather interfaces facts
@@ -30,17 +29,12 @@
register: result
junipernetworks.junos.junos_l2_interfaces:
config:
- - name: ge-0/0/1
+ - name: ge-0/0/2
trunk:
allowed_vlans:
- vlan100
- - vlan300
- native_vlan: "400"
-
- - name: ge-0/0/2
- access:
- vlan: vlan200
- state: replaced
+ native_vlan: "200"
+ state: overridden
- name: Assert that changes were applied
ansible.builtin.assert:
diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/aliases b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/aliases
deleted file mode 100644
index e69de29bb..000000000
--- a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/aliases
+++ /dev/null
diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/defaults/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/defaults/main.yaml
deleted file mode 100644
index 5f709c5aa..000000000
--- a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/defaults/main.yaml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-testcase: "*"
diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/meta/main.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/meta/main.yml
deleted file mode 100644
index d80f5fbf3..000000000
--- a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/meta/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
----
-dependencies:
- - prepare_junos_tests
diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/tasks/main.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/tasks/main.yaml
deleted file mode 100644
index eace31d3f..000000000
--- a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/tasks/main.yaml
+++ /dev/null
@@ -1,3 +0,0 @@
----
-- name: Invoke netconf
- ansible.builtin.include_tasks: netconf.yaml
diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/tasks/netconf.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/tasks/netconf.yaml
deleted file mode 100644
index 6071adcfe..000000000
--- a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/tasks/netconf.yaml
+++ /dev/null
@@ -1,21 +0,0 @@
----
-- name: Collect all netconf test cases
- ansible.builtin.find:
- paths: "{{ role_path }}/tests/netconf"
- patterns: "{{ testcase }}.yaml"
- register: test_cases
- connection: local
-
-- name: Set test_items
- ansible.builtin.set_fact:
- test_items: "{{ test_cases.files | map(attribute='path') | list }}"
-
-- name: Run test case (connection=ansible.netcommon.netconf)
- ansible.builtin.include_tasks: "{{ test_case_to_run }}"
- with_items: "{{ test_items }}"
- loop_control:
- loop_var: test_case_to_run
- vars:
- ansible_connection: ansible.netcommon.netconf
- tags:
- - netconf
diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/tests/netconf/basic.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/tests/netconf/basic.yaml
deleted file mode 100644
index 030ce9e69..000000000
--- a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_logging/tests/netconf/basic.yaml
+++ /dev/null
@@ -1,407 +0,0 @@
----
-- ansible.builtin.debug:
- msg="START junos_logging netconf/basic.yaml on connection={{ ansible_connection
- }}"
-
-- name: setup - remove file logging
- junipernetworks.junos.junos_logging:
- dest: file
- name: test
- facility: pfe
- level: error
- state: absent
-
-- name: Create file logging
- register: result
- junipernetworks.junos.junos_logging:
- dest: file
- name: test_file
- facility: pfe
- level: error
- state: present
-
-- name: Get running configuration
- register: config
- junipernetworks.junos.junos_rpc:
- rpc: get-configuration
-
-- ansible.builtin.assert:
- that:
- - result.changed == true
- - "'<name>test_file</name>' in config.xml"
- - "'<name>pfe</name>' in config.xml"
- - "'<error/>' in config.xml"
-
-- name: Create file logging (idempotent)
- register: result
- junipernetworks.junos.junos_logging:
- dest: file
- name: test_file
- facility: pfe
- level: error
- state: present
-
-- ansible.builtin.assert:
- that:
- - result.changed == false
-
-- name: Deactivate logging configuration
- register: result
- junipernetworks.junos.junos_logging:
- dest: file
- name: test_file
- facility: pfe
- level: error
- state: present
- active: false
-
-- name: Get running configuration
- register: config
- junipernetworks.junos.junos_rpc:
- rpc: get-configuration
-
-- ansible.builtin.assert:
- that:
- - result.changed == true
- - '''<file inactive="inactive">'' in config.xml'
- - '''<contents inactive="inactive">'' in config.xml'
-
-- name: Activate logging configuration
- register: result
- junipernetworks.junos.junos_logging:
- dest: file
- name: test_file
- facility: pfe
- level: error
- state: present
- active: true
-
-- name: Get running configuration
- register: config
- junipernetworks.junos.junos_rpc:
- rpc: get-configuration
-
-- ansible.builtin.assert:
- that:
- - result.changed == true
- - "'<name>test_file</name>' in config.xml"
- - "'<name>pfe</name>' in config.xml"
- - "'<error/>' in config.xml"
-
-- name: Delete logging configuration
- register: result
- junipernetworks.junos.junos_logging:
- dest: file
- name: test_file
- facility: pfe
- level: error
- state: absent
-
-- name: Get running configuration
- register: config
- junipernetworks.junos.junos_rpc:
- rpc: get-configuration
-
-- ansible.builtin.assert:
- that:
- - result.changed == true
- - "'<name>test_file</name>' not in config.xml"
-
-- name: Configure console logging
- register: result
- junipernetworks.junos.junos_logging:
- dest: console
- facility: kernel
- level: emergency
- state: present
- active: true
-
-- name: Get running configuration
- register: config
- junipernetworks.junos.junos_rpc:
- rpc: get-configuration
-
-- ansible.builtin.assert:
- that:
- - result.changed == true
- - "'<console>' in config.xml"
- - "'<name>kernel</name>' in config.xml"
- - "'<emergency/>' in config.xml"
-
-- name: Configure console logging (idempotent)
- register: result
- junipernetworks.junos.junos_logging:
- dest: console
- facility: kernel
- level: emergency
- state: present
- active: true
-
-- ansible.builtin.assert:
- that:
- - result.changed == false
-
-- name: Disable console logging
- register: result
- junipernetworks.junos.junos_logging:
- dest: console
- facility: kernel
- level: emergency
- state: present
- active: false
-
-- name: Get running configuration
- register: config
- junipernetworks.junos.junos_rpc:
- rpc: get-configuration
-
-- ansible.builtin.assert:
- that:
- - result.changed == true
- - '''<console inactive="inactive">'' in config.xml'
-
-- name: Delete console logging
- register: result
- junipernetworks.junos.junos_logging:
- dest: console
- facility: kernel
- level: emergency
- state: absent
-
-- name: Get running configuration
- register: config
- junipernetworks.junos.junos_rpc:
- rpc: get-configuration
-
-- ansible.builtin.assert:
- that:
- - result.changed == true
- - "'<console>' not in config.xml"
-
-- name: Configure logging parameters
- register: result
- junipernetworks.junos.junos_logging:
- size: 65536
- files: 40
- rotate_frequency: 20
- state: present
-
-- name: Get running configuration
- register: config
- junipernetworks.junos.junos_rpc:
- rpc: get-configuration
-
-- ansible.builtin.assert:
- that:
- - result.changed == true
- - "'<size>64k</size>' in config.xml"
- - "'<files>40</files>' in config.xml"
- - "'<log-rotate-frequency>20</log-rotate-frequency>' in config.xml"
-
-- name: Configure logging parameters (idempotent)
- register: result
- junipernetworks.junos.junos_logging:
- size: 65536
- files: 40
- rotate_frequency: 20
- state: present
- active: true
-
-- ansible.builtin.assert:
- that:
- - result.changed == false
-
-- name: Disable logging parameters
- register: result
- junipernetworks.junos.junos_logging:
- size: 65536
- files: 40
- rotate_frequency: 20
- state: present
- active: false
-
-- name: Get running configuration
- register: config
- junipernetworks.junos.junos_rpc:
- rpc: get-configuration
-
-- ansible.builtin.assert:
- that:
- - result.changed == true
- - '''<size inactive="inactive">64k</size>'' in config.xml'
- - '''<files inactive="inactive">40</files>'' in config.xml'
- - "'<log-rotate-frequency inactive=\"inactive\">20</log-rotate-frequency>'\
- \ in config.xml"
-
-- name: Activate logging parameters
- register: result
- junipernetworks.junos.junos_logging:
- size: 65536
- files: 40
- rotate_frequency: 20
- state: present
- active: true
-
-- name: Get running configuration
- register: config
- junipernetworks.junos.junos_rpc:
- rpc: get-configuration
-
-- ansible.builtin.assert:
- that:
- - result.changed == true
- - "'<size>64k</size>' in config.xml"
- - "'<files>40</files>' in config.xml"
- - "'<log-rotate-frequency>20</log-rotate-frequency>' in config.xml"
-
-- name: Delete logging parameters
- register: result
- junipernetworks.junos.junos_logging:
- size: 65536
- files: 40
- rotate_frequency: 20
- state: absent
-
-- name: Get running configuration
- register: config
- junipernetworks.junos.junos_rpc:
- rpc: get-configuration
-
-- ansible.builtin.assert:
- that:
- - result.changed == true
- - "'<size>64k</size>' not in config.xml"
- - "'<files>40</files>' not in config.xml"
- - "'<log-rotate-frequency>20</log-rotate-frequency>' not in config.xml"
-
-- name: Seup file logging using aggregate
- register: result
- junipernetworks.junos.junos_logging:
- aggregate:
- - dest: file
- name: test-1
- facility: pfe
- level: critical
- state: absent
-
- - dest: file
- name: test-2
- facility: kernel
- level: emergency
- state: absent
-
-- name: Configure file logging using aggregate
- register: result
- junipernetworks.junos.junos_logging:
- aggregate:
- - dest: file
- name: test-1
- facility: pfe
- level: critical
- active: true
-
- - dest: file
- name: test-2
- facility: kernel
- level: emergency
- active: true
-
-- ansible.builtin.assert:
- that:
- - result.changed == true
- - result.diff.prepared is search("\+ *file test-1")
- - result.diff.prepared is search("\+ *pfe critical")
- - result.diff.prepared is search("\+ *file test-2")
- - result.diff.prepared is search("\+ *kernel emergency")
-
-- name: Deactivate file logging configuration using aggregate
- register: result
- junipernetworks.junos.junos_logging:
- aggregate:
- - dest: file
- name: test-1
- facility: pfe
- level: critical
-
- - dest: file
- name: test-2
- facility: kernel
- level: emergency
- active: false
-
-- ansible.builtin.assert:
- that:
- - result.changed == true
- - result.diff.prepared is search("! *inactive[:] file test-1")
- - result.diff.prepared is search("! *inactive[:] pfe")
- - result.diff.prepared is search("! *inactive[:] file test-2")
- - result.diff.prepared is search("! *inactive[:] kernel")
-
-- name: activate file logging configuration using aggregate
- register: result
- junipernetworks.junos.junos_logging:
- aggregate:
- - dest: file
- name: test-1
- facility: pfe
- level: critical
-
- - dest: file
- name: test-2
- facility: kernel
- level: emergency
- active: true
-
-- ansible.builtin.assert:
- that:
- - result.changed == true
- - result.diff.prepared is search("! *active[:] file test-1")
- - result.diff.prepared is search("! *active[:] pfe")
- - result.diff.prepared is search("! *active[:] file test-2")
- - result.diff.prepared is search("! *active[:] kernel")
-
-- name: Delete file logging using aggregate
- register: result
- junipernetworks.junos.junos_logging:
- aggregate:
- - dest: file
- name: test-1
- facility: pfe
- level: critical
-
- - dest: file
- name: test-2
- facility: kernel
- level: emergency
- state: absent
-
-- ansible.builtin.assert:
- that:
- - result.changed == true
- - result.diff.prepared is search("\- *file test-1")
- - result.diff.prepared is search("\- *pfe critical")
- - result.diff.prepared is search("\- *file test-2")
- - result.diff.prepared is search("\- *kernel emergency")
-
-- name: Delete file logging using aggregate (idempotent)
- register: result
- junipernetworks.junos.junos_logging:
- aggregate:
- - dest: file
- name: test-1
- facility: pfe
- level: critical
-
- - dest: file
- name: test-2
- facility: kernel
- level: emergency
- state: absent
-
-- ansible.builtin.assert:
- that:
- - result.changed == false
-
-- ansible.builtin.debug:
- msg="END junos_logging netconf/basic.yaml on connection={{ ansible_connection
- }}"
diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/_reset_config.yaml b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/_reset_config.yaml
index 8ed9385eb..070a57754 100644
--- a/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/_reset_config.yaml
+++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/junos_ospf_interfaces/tests/netconf/_reset_config.yaml
@@ -1,11 +1,11 @@
---
- ansible.builtin.debug:
- msg: "START junos_ospfv3 reset config on connection={{ ansible_connection }}"
+ msg: "START reset ospf and routing-options config on connection={{ ansible_connection }}"
-- name: Reset configuration for ospf3 and routing-options
+- name: Reset configuration for ospf and routing-options
junipernetworks.junos.junos_config:
lines:
- delete protocols ospf
- delete routing-options
- ansible.builtin.debug:
- msg: "END junos_ospfv3 reset config on connection={{ ansible_connection }}"
+ msg: "END ospf and routing-options reset config on connection={{ ansible_connection }}"
diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/prepare_junos_tests/tasks/main.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/prepare_junos_tests/tasks/main.yml
index 179fb0d95..68bf6e300 100644
--- a/ansible_collections/junipernetworks/junos/tests/integration/targets/prepare_junos_tests/tasks/main.yml
+++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/prepare_junos_tests/tasks/main.yml
@@ -1,18 +1,4 @@
---
-- name: Debug task
- ansible.builtin.debug:
- msg: "START prepare_junos_tests/main.yaml"
-
-- name: Ensure netconf is enabled
- connection: ansible.netcommon.network_cli
- tags: netconf
- junipernetworks.junos.junos_netconf:
- state: present
-
-- name: Wait for netconf server to come up
- delegate_to: localhost
- tags: netconf
- ansible.builtin.wait_for:
- host: "{{ hostvars[item].ansible_host }}"
- port: 830
- with_inventory_hostnames: junos
+- name: Run the prepare steps if requested
+ ansible.builtin.include_tasks: prepare.yml
+ when: prepare_junos_tests_task | default(True) | bool
diff --git a/ansible_collections/junipernetworks/junos/tests/integration/targets/prepare_junos_tests/tasks/prepare.yml b/ansible_collections/junipernetworks/junos/tests/integration/targets/prepare_junos_tests/tasks/prepare.yml
new file mode 100644
index 000000000..179fb0d95
--- /dev/null
+++ b/ansible_collections/junipernetworks/junos/tests/integration/targets/prepare_junos_tests/tasks/prepare.yml
@@ -0,0 +1,18 @@
+---
+- name: Debug task
+ ansible.builtin.debug:
+ msg: "START prepare_junos_tests/main.yaml"
+
+- name: Ensure netconf is enabled
+ connection: ansible.netcommon.network_cli
+ tags: netconf
+ junipernetworks.junos.junos_netconf:
+ state: present
+
+- name: Wait for netconf server to come up
+ delegate_to: localhost
+ tags: netconf
+ ansible.builtin.wait_for:
+ host: "{{ hostvars[item].ansible_host }}"
+ port: 830
+ with_inventory_hostnames: junos
diff --git a/ansible_collections/junipernetworks/junos/tests/sanity/ignore-2.11.txt b/ansible_collections/junipernetworks/junos/tests/sanity/ignore-2.11.txt
deleted file mode 100644
index ed6d78dfe..000000000
--- a/ansible_collections/junipernetworks/junos/tests/sanity/ignore-2.11.txt
+++ /dev/null
@@ -1 +0,0 @@
-plugins/action/junos.py action-plugin-docs # base class for deprecated network platform modules using `connection: local`
diff --git a/ansible_collections/junipernetworks/junos/tests/sanity/ignore-2.12.txt b/ansible_collections/junipernetworks/junos/tests/sanity/ignore-2.12.txt
deleted file mode 100644
index ed6d78dfe..000000000
--- a/ansible_collections/junipernetworks/junos/tests/sanity/ignore-2.12.txt
+++ /dev/null
@@ -1 +0,0 @@
-plugins/action/junos.py action-plugin-docs # base class for deprecated network platform modules using `connection: local`
diff --git a/ansible_collections/junipernetworks/junos/tests/sanity/ignore-2.13.txt b/ansible_collections/junipernetworks/junos/tests/sanity/ignore-2.13.txt
deleted file mode 100644
index ed6d78dfe..000000000
--- a/ansible_collections/junipernetworks/junos/tests/sanity/ignore-2.13.txt
+++ /dev/null
@@ -1 +0,0 @@
-plugins/action/junos.py action-plugin-docs # base class for deprecated network platform modules using `connection: local`
diff --git a/ansible_collections/junipernetworks/junos/tests/sanity/ignore-2.10.txt b/ansible_collections/junipernetworks/junos/tests/sanity/ignore-2.18.txt
index ed6d78dfe..ed6d78dfe 100644
--- a/ansible_collections/junipernetworks/junos/tests/sanity/ignore-2.10.txt
+++ b/ansible_collections/junipernetworks/junos/tests/sanity/ignore-2.18.txt
diff --git a/ansible_collections/junipernetworks/junos/tests/sanity/ignore-2.9.txt b/ansible_collections/junipernetworks/junos/tests/sanity/ignore-2.9.txt
deleted file mode 100644
index e6e2e3680..000000000
--- a/ansible_collections/junipernetworks/junos/tests/sanity/ignore-2.9.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-plugins/action/junos.py action-plugin-docs # base class for deprecated network platform modules using `connection: local`
-plugins/modules/junos_logging.py validate-modules:deprecation-mismatch # 2.9 expects METADATA
-plugins/modules/junos_logging.py validate-modules:invalid-documentation # removed_at_date not supported in `deprecated` dict
-plugins/modules/junos_scp.py validate-modules:deprecation-mismatch # 2.9 expects METADATA
-plugins/modules/junos_scp.py validate-modules:invalid-documentation # removed_at_date not supported in `deprecated` dict
diff --git a/ansible_collections/junipernetworks/junos/tests/unit/compat/__init__.py b/ansible_collections/junipernetworks/junos/tests/unit/compat/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/ansible_collections/junipernetworks/junos/tests/unit/compat/__init__.py
+++ /dev/null
diff --git a/ansible_collections/junipernetworks/junos/tests/unit/compat/mock.py b/ansible_collections/junipernetworks/junos/tests/unit/compat/mock.py
deleted file mode 100644
index 860a9e84b..000000000
--- a/ansible_collections/junipernetworks/junos/tests/unit/compat/mock.py
+++ /dev/null
@@ -1,130 +0,0 @@
-# (c) 2014, Toshio Kuratomi <tkuratomi@ansible.com>
-#
-# This file is part of Ansible
-#
-# Ansible is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Ansible is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import absolute_import, division, print_function
-
-
-__metaclass__ = type
-
-import _io
-
-
-"""
-Compat module for Python3.x's unittest.mock module
-"""
-import sys
-
-
-# Python 2.7
-
-# Note: Could use the pypi mock library on python3.x as well as python2.x. It
-# is the same as the python3 stdlib mock library
-
-try:
- # Allow wildcard import because we really do want to import all of mock's
- # symbols into this compat shim
- # pylint: disable=wildcard-import,unused-wildcard-import
- from unittest.mock import *
-except ImportError:
- # Python 2
- # pylint: disable=wildcard-import,unused-wildcard-import
- try:
- from mock import *
- except ImportError:
- print("You need the mock library installed on python2.x to run tests")
-
-
-# Prior to 3.4.4, mock_open cannot handle binary read_data
-if sys.version_info >= (3,) and sys.version_info < (3, 4, 4):
- file_spec = None
-
- def _iterate_read_data(read_data):
- # Helper for mock_open:
- # Retrieve lines from read_data via a generator so that separate calls to
- # readline, read, and readlines are properly interleaved
- sep = b"\n" if isinstance(read_data, bytes) else "\n"
- data_as_list = [l + sep for l in read_data.split(sep)]
-
- if data_as_list[-1] == sep:
- # If the last line ended in a newline, the list comprehension will have an
- # extra entry that's just a newline. Remove this.
- data_as_list = data_as_list[:-1]
- else:
- # If there wasn't an extra newline by itself, then the file being
- # emulated doesn't have a newline to end the last line remove the
- # newline that our naive format() added
- data_as_list[-1] = data_as_list[-1][:-1]
-
- for line in data_as_list:
- yield line
-
- def mock_open(mock=None, read_data=""):
- """
- A helper function to create a mock to replace the use of `open`. It works
- for `open` called directly or used as a context manager.
-
- The `mock` argument is the mock object to configure. If `None` (the
- default) then a `MagicMock` will be created for you, with the API limited
- to methods or attributes available on standard file handles.
-
- `read_data` is a string for the `read` methoddline`, and `readlines` of the
- file handle to return. This is an empty string by default.
- """
-
- def _readlines_side_effect(*args, **kwargs):
- if handle.readlines.return_value is not None:
- return handle.readlines.return_value
- return list(_data)
-
- def _read_side_effect(*args, **kwargs):
- if handle.read.return_value is not None:
- return handle.read.return_value
- return type(read_data)().join(_data)
-
- def _readline_side_effect():
- if handle.readline.return_value is not None:
- while True:
- yield handle.readline.return_value
- for line in _data:
- yield line
-
- global file_spec
- if file_spec is None:
- file_spec = list(
- set(dir(_io.TextIOWrapper)).union(set(dir(_io.BytesIO))),
- )
-
- if mock is None:
- mock = MagicMock(name="open", spec=open)
-
- handle = MagicMock(spec=file_spec)
- handle.__enter__.return_value = handle
-
- _data = _iterate_read_data(read_data)
-
- handle.write.return_value = None
- handle.read.return_value = None
- handle.readline.return_value = None
- handle.readlines.return_value = None
-
- handle.read.side_effect = _read_side_effect
- handle.readline.side_effect = _readline_side_effect()
- handle.readlines.side_effect = _readlines_side_effect
-
- mock.return_value = handle
- return mock
diff --git a/ansible_collections/junipernetworks/junos/tests/unit/compat/unittest.py b/ansible_collections/junipernetworks/junos/tests/unit/compat/unittest.py
deleted file mode 100644
index df4266ec9..000000000
--- a/ansible_collections/junipernetworks/junos/tests/unit/compat/unittest.py
+++ /dev/null
@@ -1,41 +0,0 @@
-# (c) 2014, Toshio Kuratomi <tkuratomi@ansible.com>
-#
-# This file is part of Ansible
-#
-# Ansible is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Ansible is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import absolute_import, division, print_function
-
-
-__metaclass__ = type
-
-"""
-Compat module for Python2.7's unittest module
-"""
-
-import sys
-
-
-# Allow wildcard import because we really do want to import all of
-# unittests's symbols into this compat shim
-# pylint: disable=wildcard-import,unused-wildcard-import
-if sys.version_info < (2, 7):
- try:
- # Need unittest2 on python2.6
- from unittest2 import *
- except ImportError:
- print("You need unittest2 installed on python2.6.x to run tests")
-else:
- from unittest import *
diff --git a/ansible_collections/junipernetworks/junos/tests/unit/mock/path.py b/ansible_collections/junipernetworks/junos/tests/unit/mock/path.py
index a7171080e..7d287a5fb 100644
--- a/ansible_collections/junipernetworks/junos/tests/unit/mock/path.py
+++ b/ansible_collections/junipernetworks/junos/tests/unit/mock/path.py
@@ -2,9 +2,9 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
-from ansible.utils.path import unfrackpath
+from unittest.mock import MagicMock
-from ansible_collections.junipernetworks.junos.tests.unit.compat.mock import MagicMock
+from ansible.utils.path import unfrackpath
mock_unfrackpath_noop = MagicMock(
diff --git a/ansible_collections/junipernetworks/junos/tests/unit/mock/procenv.py b/ansible_collections/junipernetworks/junos/tests/unit/mock/procenv.py
index 79f2f97ca..e6e09464b 100644
--- a/ansible_collections/junipernetworks/junos/tests/unit/mock/procenv.py
+++ b/ansible_collections/junipernetworks/junos/tests/unit/mock/procenv.py
@@ -27,12 +27,11 @@ import sys
from contextlib import contextmanager
from io import BytesIO, StringIO
+from unittest import TestCase
from ansible.module_utils._text import to_bytes
from ansible.module_utils.six import PY3
-from ansible_collections.junipernetworks.junos.tests.unit.compat import unittest
-
@contextmanager
def swap_stdin_and_argv(stdin_data="", argv_data=tuple()):
@@ -78,7 +77,7 @@ def swap_stdout():
sys.stdout = old_stdout
-class ModuleTestCase(unittest.TestCase):
+class ModuleTestCase(TestCase):
def setUp(self, module_args=None):
if module_args is None:
module_args = {
diff --git a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_bgp_address_family.py b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_bgp_address_family.py
index f28cb61a0..5a743bee7 100644
--- a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_bgp_address_family.py
+++ b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_bgp_address_family.py
@@ -26,8 +26,9 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
+from unittest.mock import patch
+
from ansible_collections.junipernetworks.junos.plugins.modules import junos_bgp_address_family
-from ansible_collections.junipernetworks.junos.tests.unit.compat.mock import patch
from ansible_collections.junipernetworks.junos.tests.unit.modules.utils import set_module_args
from .junos_module import TestJunosModule, load_fixture
diff --git a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_bgp_global.py b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_bgp_global.py
index f1d377494..f5d8dfcd5 100644
--- a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_bgp_global.py
+++ b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_bgp_global.py
@@ -26,8 +26,9 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
+from unittest.mock import patch
+
from ansible_collections.junipernetworks.junos.plugins.modules import junos_bgp_global
-from ansible_collections.junipernetworks.junos.tests.unit.compat.mock import patch
from ansible_collections.junipernetworks.junos.tests.unit.modules.utils import set_module_args
from .junos_module import TestJunosModule, load_fixture
diff --git a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_command.py b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_command.py
index 720b32981..5e0669577 100644
--- a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_command.py
+++ b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_command.py
@@ -26,8 +26,9 @@ try:
except ImportError:
from xml.etree.ElementTree import fromstring
+from unittest.mock import patch
+
from ansible_collections.junipernetworks.junos.plugins.modules import junos_command
-from ansible_collections.junipernetworks.junos.tests.unit.compat.mock import patch
from ansible_collections.junipernetworks.junos.tests.unit.modules.utils import set_module_args
from .junos_module import TestJunosModule, load_fixture
diff --git a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_config.py b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_config.py
index f3adb4767..e24a56c47 100644
--- a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_config.py
+++ b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_config.py
@@ -22,10 +22,11 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
+from unittest.mock import patch
+
from ansible.module_utils._text import to_text
from ansible_collections.junipernetworks.junos.plugins.modules import junos_config
-from ansible_collections.junipernetworks.junos.tests.unit.compat.mock import patch
from ansible_collections.junipernetworks.junos.tests.unit.modules.utils import set_module_args
from .junos_module import TestJunosModule, load_fixture
diff --git a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_facts.py b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_facts.py
index 1e6bc12d3..154ea4f50 100644
--- a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_facts.py
+++ b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_facts.py
@@ -26,8 +26,9 @@ try:
except ImportError:
from xml.etree.ElementTree import fromstring
+from unittest.mock import patch
+
from ansible_collections.junipernetworks.junos.plugins.modules import junos_facts
-from ansible_collections.junipernetworks.junos.tests.unit.compat.mock import patch
from ansible_collections.junipernetworks.junos.tests.unit.modules.utils import set_module_args
from .junos_module import TestJunosModule, load_fixture
diff --git a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_hostname.py b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_hostname.py
index a6c40395f..8fe1931d7 100644
--- a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_hostname.py
+++ b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_hostname.py
@@ -26,8 +26,9 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
+from unittest.mock import patch
+
from ansible_collections.junipernetworks.junos.plugins.modules import junos_hostname
-from ansible_collections.junipernetworks.junos.tests.unit.compat.mock import patch
from ansible_collections.junipernetworks.junos.tests.unit.modules.utils import set_module_args
from .junos_module import TestJunosModule, load_fixture
diff --git a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_interfaces.py b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_interfaces.py
index 55ee8c766..d2f41bf6c 100644
--- a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_interfaces.py
+++ b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_interfaces.py
@@ -26,8 +26,9 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
+from unittest.mock import patch
+
from ansible_collections.junipernetworks.junos.plugins.modules import junos_interfaces
-from ansible_collections.junipernetworks.junos.tests.unit.compat.mock import patch
from ansible_collections.junipernetworks.junos.tests.unit.modules.utils import set_module_args
from .junos_module import TestJunosModule, load_fixture
diff --git a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_l2_interfaces.py b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_l2_interfaces.py
index 1524047f5..06d61143e 100644
--- a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_l2_interfaces.py
+++ b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_l2_interfaces.py
@@ -26,8 +26,9 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
+from unittest.mock import patch
+
from ansible_collections.junipernetworks.junos.plugins.modules import junos_l2_interfaces
-from ansible_collections.junipernetworks.junos.tests.unit.compat.mock import patch
from ansible_collections.junipernetworks.junos.tests.unit.modules.utils import set_module_args
from .junos_module import TestJunosModule, load_fixture
diff --git a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_l3_interfaces.py b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_l3_interfaces.py
index dba2e4b7d..600861a68 100644
--- a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_l3_interfaces.py
+++ b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_l3_interfaces.py
@@ -26,8 +26,9 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
+from unittest.mock import patch
+
from ansible_collections.junipernetworks.junos.plugins.modules import junos_l3_interfaces
-from ansible_collections.junipernetworks.junos.tests.unit.compat.mock import patch
from ansible_collections.junipernetworks.junos.tests.unit.modules.utils import set_module_args
from .junos_module import TestJunosModule, load_fixture
diff --git a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_logging_global.py b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_logging_global.py
index d1046c14c..55ac5170a 100644
--- a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_logging_global.py
+++ b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_logging_global.py
@@ -26,8 +26,9 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
+from unittest.mock import patch
+
from ansible_collections.junipernetworks.junos.plugins.modules import junos_logging_global
-from ansible_collections.junipernetworks.junos.tests.unit.compat.mock import patch
from ansible_collections.junipernetworks.junos.tests.unit.modules.utils import set_module_args
from .junos_module import TestJunosModule, load_fixture
diff --git a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_netconf.py b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_netconf.py
index 8f98536c7..70e4fe0b2 100644
--- a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_netconf.py
+++ b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_netconf.py
@@ -21,8 +21,9 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
+from unittest.mock import patch
+
from ansible_collections.junipernetworks.junos.plugins.modules import junos_netconf
-from ansible_collections.junipernetworks.junos.tests.unit.compat.mock import patch
from ansible_collections.junipernetworks.junos.tests.unit.modules.utils import set_module_args
from .junos_module import TestJunosModule
diff --git a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_ntp_global.py b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_ntp_global.py
index d99faf11a..26836a7c4 100644
--- a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_ntp_global.py
+++ b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_ntp_global.py
@@ -26,8 +26,9 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
+from unittest.mock import patch
+
from ansible_collections.junipernetworks.junos.plugins.modules import junos_ntp_global
-from ansible_collections.junipernetworks.junos.tests.unit.compat.mock import patch
from ansible_collections.junipernetworks.junos.tests.unit.modules.utils import set_module_args
from .junos_module import TestJunosModule, load_fixture
diff --git a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_ospf_interfaces.py b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_ospf_interfaces.py
index e57a65955..39ea2b77d 100644
--- a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_ospf_interfaces.py
+++ b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_ospf_interfaces.py
@@ -26,8 +26,9 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
+from unittest.mock import MagicMock, patch
+
from ansible_collections.junipernetworks.junos.plugins.modules import junos_ospf_interfaces
-from ansible_collections.junipernetworks.junos.tests.unit.compat.mock import MagicMock, patch
from ansible_collections.junipernetworks.junos.tests.unit.modules.utils import set_module_args
from .junos_module import TestJunosModule, load_fixture
diff --git a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_ospfv2.py b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_ospfv2.py
index 593acd831..3ec9f589c 100644
--- a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_ospfv2.py
+++ b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_ospfv2.py
@@ -26,8 +26,9 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
+from unittest.mock import patch
+
from ansible_collections.junipernetworks.junos.plugins.modules import junos_ospfv2
-from ansible_collections.junipernetworks.junos.tests.unit.compat.mock import patch
from ansible_collections.junipernetworks.junos.tests.unit.modules.utils import set_module_args
from .junos_module import TestJunosModule, load_fixture
@@ -567,7 +568,7 @@ class TestJunosOspfv2Module(TestJunosModule):
result = self.execute_module(changed=True, commands=commands)
self.assertEqual(sorted(result["commands"]), sorted(commands))
- def test_junos_ospfv2_rendered(self):
+ def test_junos_ospfv2_deleted(self):
set_module_args(
dict(
config=[],
@@ -576,11 +577,13 @@ class TestJunosOspfv2Module(TestJunosModule):
)
commands = [
'<nc:protocols xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"><nc:ospf>'
- '<nc:area delete="delete">0.0.0.100</nc:area><nc:spf-options delete="delete"/>'
- '<nc:reference-bandwidth delete="delete"/><nc:no-rfc-1583 delete="delete"/>'
- '<nc:overload delete="delete"/></nc:ospf></nc:protocols>',
+ '<nc:area delete="delete">0.0.0.100</nc:area><nc:area delete="delete">0.0.0.200</nc:area>'
+ '<nc:spf-options delete="delete"/><nc:reference-bandwidth delete="delete"/>'
+ '<nc:no-rfc-1583 delete="delete"/><nc:overload delete="delete"/>'
+ '<nc:prefix-export-limit delete="delete"/></nc:ospf></nc:protocols>',
]
result = self.execute_module(changed=True, commands=commands)
+
self.assertEqual(sorted(result["commands"]), sorted(commands))
def test_junos_ospfv2_parsed(self):
diff --git a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_ospfv3.py b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_ospfv3.py
index a96d95bac..beef248b3 100644
--- a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_ospfv3.py
+++ b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_ospfv3.py
@@ -26,8 +26,9 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
+from unittest.mock import MagicMock, patch
+
from ansible_collections.junipernetworks.junos.plugins.modules import junos_ospfv3
-from ansible_collections.junipernetworks.junos.tests.unit.compat.mock import MagicMock, patch
from ansible_collections.junipernetworks.junos.tests.unit.modules.utils import set_module_args
from .junos_module import TestJunosModule, load_fixture
diff --git a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_package.py b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_package.py
index f679fa5a3..943c7e9e0 100644
--- a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_package.py
+++ b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_package.py
@@ -21,7 +21,8 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
-from ansible_collections.junipernetworks.junos.tests.unit.compat.mock import MagicMock, patch
+from unittest.mock import MagicMock, patch
+
from ansible_collections.junipernetworks.junos.tests.unit.modules.utils import set_module_args
from .junos_module import TestJunosModule
diff --git a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_ping.py b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_ping.py
index da101d418..4a6d27011 100644
--- a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_ping.py
+++ b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_ping.py
@@ -21,8 +21,9 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
+from unittest.mock import MagicMock, patch
+
from ansible_collections.junipernetworks.junos.plugins.modules import junos_ping
-from ansible_collections.junipernetworks.junos.tests.unit.compat.mock import MagicMock, patch
from ansible_collections.junipernetworks.junos.tests.unit.modules.utils import set_module_args
from .junos_module import TestJunosModule, load_fixture
diff --git a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_prefix_lists.py b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_prefix_lists.py
index d46b38684..9db905a4c 100644
--- a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_prefix_lists.py
+++ b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_prefix_lists.py
@@ -26,8 +26,9 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
+from unittest.mock import patch
+
from ansible_collections.junipernetworks.junos.plugins.modules import junos_prefix_lists
-from ansible_collections.junipernetworks.junos.tests.unit.compat.mock import patch
from ansible_collections.junipernetworks.junos.tests.unit.modules.utils import set_module_args
from .junos_module import TestJunosModule, load_fixture
diff --git a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_routing_instances.py b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_routing_instances.py
index 5d656852d..214bddb80 100644
--- a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_routing_instances.py
+++ b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_routing_instances.py
@@ -26,8 +26,9 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
+from unittest.mock import patch
+
from ansible_collections.junipernetworks.junos.plugins.modules import junos_routing_instances
-from ansible_collections.junipernetworks.junos.tests.unit.compat.mock import patch
from ansible_collections.junipernetworks.junos.tests.unit.modules.utils import set_module_args
from .junos_module import TestJunosModule, load_fixture
diff --git a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_routing_options.py b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_routing_options.py
index 2f80838b0..0f506bc8c 100644
--- a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_routing_options.py
+++ b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_routing_options.py
@@ -26,8 +26,9 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
+from unittest.mock import patch
+
from ansible_collections.junipernetworks.junos.plugins.modules import junos_routing_options
-from ansible_collections.junipernetworks.junos.tests.unit.compat.mock import patch
from ansible_collections.junipernetworks.junos.tests.unit.modules.utils import set_module_args
from .junos_module import TestJunosModule, load_fixture
diff --git a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_rpc.py b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_rpc.py
index 4c914aa3d..11a3bb8a2 100644
--- a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_rpc.py
+++ b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_rpc.py
@@ -26,8 +26,9 @@ try:
except ImportError:
from xml.etree.ElementTree import fromstring
+from unittest.mock import patch
+
from ansible_collections.junipernetworks.junos.plugins.modules import junos_rpc
-from ansible_collections.junipernetworks.junos.tests.unit.compat.mock import patch
from ansible_collections.junipernetworks.junos.tests.unit.modules.utils import set_module_args
from .junos_module import TestJunosModule, load_fixture
diff --git a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_scp.py b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_scp.py
index 0788d6523..fc2bd1b82 100644
--- a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_scp.py
+++ b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_scp.py
@@ -23,7 +23,8 @@ __metaclass__ = type
import os
-from ansible_collections.junipernetworks.junos.tests.unit.compat.mock import MagicMock, patch
+from unittest.mock import MagicMock, patch
+
from ansible_collections.junipernetworks.junos.tests.unit.modules.utils import set_module_args
from .junos_module import TestJunosModule
diff --git a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_security_policies.py b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_security_policies.py
index b41161672..22eb2b14c 100644
--- a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_security_policies.py
+++ b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_security_policies.py
@@ -26,8 +26,9 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
+from unittest.mock import patch
+
from ansible_collections.junipernetworks.junos.plugins.modules import junos_security_policies
-from ansible_collections.junipernetworks.junos.tests.unit.compat.mock import patch
from ansible_collections.junipernetworks.junos.tests.unit.modules.utils import set_module_args
from .junos_module import TestJunosModule, load_fixture
diff --git a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_security_policies_global.py b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_security_policies_global.py
index 1dd375233..1c1131d90 100644
--- a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_security_policies_global.py
+++ b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_security_policies_global.py
@@ -26,8 +26,9 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
+from unittest.mock import patch
+
from ansible_collections.junipernetworks.junos.plugins.modules import junos_security_policies_global
-from ansible_collections.junipernetworks.junos.tests.unit.compat.mock import patch
from ansible_collections.junipernetworks.junos.tests.unit.modules.utils import set_module_args
from .junos_module import TestJunosModule, load_fixture
diff --git a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_security_zones.py b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_security_zones.py
index 764d1a7e8..b5eb03851 100644
--- a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_security_zones.py
+++ b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_security_zones.py
@@ -26,8 +26,9 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
+from unittest.mock import patch
+
from ansible_collections.junipernetworks.junos.plugins.modules import junos_security_zones
-from ansible_collections.junipernetworks.junos.tests.unit.compat.mock import patch
from ansible_collections.junipernetworks.junos.tests.unit.modules.utils import set_module_args
from .junos_module import TestJunosModule, load_fixture
diff --git a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_snmp_server.py b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_snmp_server.py
index ed73b8c5a..f29381a19 100644
--- a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_snmp_server.py
+++ b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_snmp_server.py
@@ -26,8 +26,9 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
+from unittest.mock import patch
+
from ansible_collections.junipernetworks.junos.plugins.modules import junos_snmp_server
-from ansible_collections.junipernetworks.junos.tests.unit.compat.mock import patch
from ansible_collections.junipernetworks.junos.tests.unit.modules.utils import set_module_args
from .junos_module import TestJunosModule, load_fixture
diff --git a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_vlans.py b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_vlans.py
index c6f33fc12..1f0890a51 100644
--- a/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_vlans.py
+++ b/ansible_collections/junipernetworks/junos/tests/unit/modules/network/junos/test_junos_vlans.py
@@ -26,8 +26,9 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
+from unittest.mock import patch
+
from ansible_collections.junipernetworks.junos.plugins.modules import junos_vlans
-from ansible_collections.junipernetworks.junos.tests.unit.compat.mock import patch
from ansible_collections.junipernetworks.junos.tests.unit.modules.utils import set_module_args
from .junos_module import TestJunosModule, load_fixture
diff --git a/ansible_collections/junipernetworks/junos/tests/unit/modules/utils.py b/ansible_collections/junipernetworks/junos/tests/unit/modules/utils.py
index d1cc4ec53..87be9cf8e 100644
--- a/ansible_collections/junipernetworks/junos/tests/unit/modules/utils.py
+++ b/ansible_collections/junipernetworks/junos/tests/unit/modules/utils.py
@@ -4,12 +4,12 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
import json
+from unittest import TestCase
+from unittest.mock import patch
+
from ansible.module_utils import basic
from ansible.module_utils._text import to_bytes
-from ansible_collections.junipernetworks.junos.tests.unit.compat import unittest
-from ansible_collections.junipernetworks.junos.tests.unit.compat.mock import patch
-
def set_module_args(args):
if "_ansible_remote_tmp" not in args:
@@ -40,7 +40,7 @@ def fail_json(*args, **kwargs):
raise AnsibleFailJson(kwargs)
-class ModuleTestCase(unittest.TestCase):
+class ModuleTestCase(TestCase):
def setUp(self):
self.mock_module = patch.multiple(
basic.AnsibleModule,