From cbdac4598361e8ad968d396bda11ed29175ae427 Mon Sep 17 00:00:00 2001 From: Jeenitkumar Khatri Date: Tue, 2 Jul 2024 16:53:46 +0530 Subject: [PATCH] [FIX] Updated unit test case by replacing called_once_with to assert_called_once_with for python3.12 --- .github/workflows/ansible-test.yml | 12 +++++------ MANIFEST.in | 0 plugins/lookup/nios_next_ip.py | 8 +++++-- tests/unit/plugins/module_utils/test_api.py | 18 +++++++++------- .../plugins/modules/test_nios_a_record.py | 17 ++++++++------- .../plugins/modules/test_nios_aaaa_record.py | 19 +++++++++++------ .../plugins/modules/test_nios_cname_record.py | 8 +++++-- .../plugins/modules/test_nios_dns_view.py | 7 ++++++- .../modules/test_nios_dtc_monitor_http.py | 4 +++- .../modules/test_nios_dtc_monitor_icmp.py | 4 +++- .../modules/test_nios_dtc_monitor_pdp.py | 4 +++- .../modules/test_nios_dtc_monitor_sip.py | 5 +++-- .../modules/test_nios_dtc_monitor_snmp.py | 5 +++-- .../modules/test_nios_dtc_monitor_tcp.py | 4 +++- .../plugins/modules/test_nios_dtc_topology.py | 5 +++-- .../modules/test_nios_fixed_address.py | 13 +++++++++++- .../plugins/modules/test_nios_host_record.py | 17 +++++++++------ .../unit/plugins/modules/test_nios_member.py | 10 +++++++-- .../plugins/modules/test_nios_mx_record.py | 6 ++++-- .../plugins/modules/test_nios_naptr_record.py | 5 ++++- .../unit/plugins/modules/test_nios_network.py | 8 +++++-- .../plugins/modules/test_nios_network_view.py | 21 ++++++++++++------- .../unit/plugins/modules/test_nios_nsgroup.py | 7 +++++-- .../plugins/modules/test_nios_ptr_record.py | 16 ++++++++------ .../plugins/modules/test_nios_srv_record.py | 6 ++++-- tests/unit/plugins/modules/test_nios_zone.py | 5 +++-- tests/unit/requirements.txt | 3 +-- 27 files changed, 160 insertions(+), 77 deletions(-) create mode 100644 MANIFEST.in diff --git a/.github/workflows/ansible-test.yml b/.github/workflows/ansible-test.yml index ed40dd7c..93867d61 100644 --- a/.github/workflows/ansible-test.yml +++ b/.github/workflows/ansible-test.yml @@ -18,10 +18,10 @@ jobs: - name: Check out code uses: actions/checkout@v2 - - name: Set up Python 3.10 + - name: Set up Python 3.11 uses: actions/setup-python@v1 with: - python-version: '3.10' + python-version: '3.11' - name: Install ansible (${{ matrix.ansible-version }}) run: pip install pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible-version }}.tar.gz --disable-pip-version-check @@ -93,8 +93,8 @@ jobs: - name: Generate coverage report run: | - if [ "${{ matrix.ansible-version }}" == "stable-2.16" ]; then - pip install coverage==7.3.2; + if [ "${{ matrix.ansible-version }}" == "devel" ]; then + pip install coverage==7.5.3; elif [ "${{ matrix.ansible-version }}" == "stable-2.15" ]; then pip install coverage==6.5.0; fi @@ -189,12 +189,12 @@ jobs: ansible-version: [stable-2.15, stable-2.16, stable-2.17, devel] steps: - - name: Set up Python 3.10 + - name: Set up Python 3.11 uses: actions/setup-python@v1 with: # it is just required to run that once as "ansible-test sanity" in the docker image # will run on all python versions it supports. - python-version: '3.10' + python-version: 3.11 - name: Install ansible (${{ matrix.ansible-version }}) version run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible-version }}.tar.gz --disable-pip-version-check diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 00000000..e69de29b diff --git a/plugins/lookup/nios_next_ip.py b/plugins/lookup/nios_next_ip.py index d084ad4f..6d79745a 100644 --- a/plugins/lookup/nios_next_ip.py +++ b/plugins/lookup/nios_next_ip.py @@ -53,8 +53,12 @@ - name: return the next 3 available IP addresses for network 192.168.10.0/24 ansible.builtin.set_fact: - ipaddr: "{{ lookup('infoblox.nios_modules.nios_next_ip', '192.168.10.0/24', num=3, - provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" + ipaddr: "{{ lookup('infoblox.nios_modules.nios_next_ip', + '192.168.10.0/24', + num=3, + provider={'host': 'nios01', + 'username': 'admin', + 'password': 'password'}) }}" - name: return the next 3 available IP addresses for network 192.168.10.0/24 excluding ip addresses - ['192.168.10.1', '192.168.10.2'] ansible.builtin.set_fact: diff --git a/tests/unit/plugins/module_utils/test_api.py b/tests/unit/plugins/module_utils/test_api.py index 6ebf5bad..73911a8d 100644 --- a/tests/unit/plugins/module_utils/test_api.py +++ b/tests/unit/plugins/module_utils/test_api.py @@ -79,11 +79,11 @@ def test_wapi_no_change(self): def test_wapi_change(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'default', 'comment': 'updated comment', 'extattrs': None} - + ref = "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "name": "default", "extattrs": {} } @@ -99,16 +99,16 @@ def test_wapi_change(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) - wapi.update_object.assert_called_once_with(test_object) + wapi.update_object.assert_called_once_with(ref, {'comment': 'updated comment', 'name': 'default'}) def test_wapi_change_false(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'default', 'comment': 'updated comment', 'extattrs': None, 'fqdn': 'foo'} - + ref = "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "name": "default", "extattrs": {} } @@ -125,7 +125,9 @@ def test_wapi_change_false(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) - wapi.update_object.assert_called_once_with(test_object) + wapi.update_object.assert_called_once_with( + ref, {'comment': 'updated comment', 'name': 'default'} + ) def test_wapi_extattrs_change(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'default', @@ -161,9 +163,10 @@ def test_wapi_extattrs_nochange(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'default', 'comment': 'test comment', 'extattrs': {'Site': 'test'}} + ref = "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [{ "comment": "test comment", - "_ref": "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "name": "default", "extattrs": {'Site': {'value': 'test'}} }] @@ -178,6 +181,7 @@ def test_wapi_extattrs_nochange(self): res = wapi.run('testobject', test_spec) self.assertFalse(res['changed']) + wapi.update_object.assert_not_called() def test_wapi_create(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'ansible', diff --git a/tests/unit/plugins/modules/test_nios_a_record.py b/tests/unit/plugins/modules/test_nios_a_record.py index e0aaf923..164a93a7 100644 --- a/tests/unit/plugins/modules/test_nios_a_record.py +++ b/tests/unit/plugins/modules/test_nios_a_record.py @@ -53,7 +53,7 @@ def _get_wapi(self, test_object): wapi = api.WapiModule(self.module) wapi.get_object = Mock(name='get_object', return_value=test_object) wapi.create_object = Mock(name='create_object') - wapi.update_object = Mock(name='update_object') + wapi.update_object = Mock(name='update_object', ) wapi.delete_object = Mock(name='delete_object') return wapi @@ -86,10 +86,11 @@ def test_nios_a_record_update_comment(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'a.ansible.com', 'ipv4': '192.168.10.1', 'comment': 'updated comment', 'extattrs': None} + ref = "arecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "arecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "name": "a.ansible.com", "ipv4": "192.168.10.1", "extattrs": {} @@ -105,8 +106,10 @@ def test_nios_a_record_update_comment(self): wapi = self._get_wapi(test_object) res = wapi.run('testobject', test_spec) - self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with( + ref, {'comment': 'updated comment', 'ipv4': '192.168.10.1', 'name': 'a.ansible.com'} + ) def test_nios_a_record_remove(self): self.module.params = {'provider': None, 'state': 'absent', 'name': 'a.ansible.com', 'ipv4': '192.168.10.1', @@ -139,12 +142,12 @@ def test_nios_a_record_update_record_name(self): self.module.params = {'provider': None, 'state': 'present', 'name': {'new_name': 'a_new.ansible.com', 'old_name': 'a.ansible.com'}, 'comment': 'comment', 'extattrs': None} + ref = "arecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "arecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", - "name": "a_new.ansible.com", - "old_name": "a.ansible.com", + "_ref": ref, + "name": "a.ansible.com", "extattrs": {} } ] @@ -159,4 +162,4 @@ def test_nios_a_record_update_record_name(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) - wapi.update_object.assert_called_once_with(test_object) + wapi.update_object.assert_called_once_with(ref, {'name': 'a_new.ansible.com', 'comment': 'comment'}) diff --git a/tests/unit/plugins/modules/test_nios_aaaa_record.py b/tests/unit/plugins/modules/test_nios_aaaa_record.py index c53797a3..10b6e18d 100644 --- a/tests/unit/plugins/modules/test_nios_aaaa_record.py +++ b/tests/unit/plugins/modules/test_nios_aaaa_record.py @@ -86,10 +86,11 @@ def test_nios_aaaa_record_update_comment(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'aaaa.ansible.com', 'ipv6': '2001:0db8:85a3:0000:0000:8a2e:0370:7334', 'comment': 'updated comment', 'extattrs': None} + ref = "aaaarecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "aaaarecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "name": "aaaa.ansible.com", "ipv6": "2001:0db8:85a3:0000:0000:8a2e:0370:7334", "extattrs": {} @@ -107,6 +108,10 @@ def test_nios_aaaa_record_update_comment(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with( + ref, + {'comment': 'updated comment', 'ipv6': '2001:0db8:85a3:0000:0000:8a2e:0370:7334', 'name': 'aaaa.ansible.com'} + ) def test_nios_aaaa_record_remove(self): self.module.params = {'provider': None, 'state': 'absent', 'name': 'aaaa.ansible.com', @@ -138,13 +143,12 @@ def test_nios_aaaa_record_remove(self): def test_nios_aaaa_record_update_record_name(self): self.module.params = {'provider': None, 'state': 'present', 'name': {'new_name': 'aaaa_new.ansible.com', 'old_name': 'aaaa.ansible.com'}, 'comment': 'comment', 'extattrs': None} - + ref = "aaaarecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "aaaarecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", - "name": "aaaa_new.ansible.com", - "old_name": "aaaa.ansible.com", + "_ref": ref, + "name": "aaaa.ansible.com", "extattrs": {} } ] @@ -159,4 +163,7 @@ def test_nios_aaaa_record_update_record_name(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) - wapi.update_object.assert_called_once_with(test_object) + wapi.update_object.assert_called_once_with( + ref, + {'comment': 'comment', 'name': 'aaaa_new.ansible.com'} + ) diff --git a/tests/unit/plugins/modules/test_nios_cname_record.py b/tests/unit/plugins/modules/test_nios_cname_record.py index 360a9cc9..3ad17abd 100644 --- a/tests/unit/plugins/modules/test_nios_cname_record.py +++ b/tests/unit/plugins/modules/test_nios_cname_record.py @@ -85,11 +85,11 @@ def test_nios_cname_record_create(self): def test_nios_cname_record_update_comment(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'cname.ansible.com', 'canonical': 'realhost.ansible.com', 'comment': 'updated comment', 'extattrs': None} - + ref = "cnamerecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "cnamerecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "name": "cname.ansible.com", "canonical": "realhost.ansible.com", "extattrs": {} @@ -107,6 +107,10 @@ def test_nios_cname_record_update_comment(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with( + ref, + {'comment': 'updated comment', 'name': 'cname.ansible.com', 'canonical': 'realhost.ansible.com'} + ) def test_nios_cname_record_remove(self): self.module.params = {'provider': None, 'state': 'absent', 'name': 'cname.ansible.com', diff --git a/tests/unit/plugins/modules/test_nios_dns_view.py b/tests/unit/plugins/modules/test_nios_dns_view.py index b4933b55..ba003c8f 100644 --- a/tests/unit/plugins/modules/test_nios_dns_view.py +++ b/tests/unit/plugins/modules/test_nios_dns_view.py @@ -58,6 +58,9 @@ def _get_wapi(self, test_object): return wapi def load_fixtures(self, commands=None): + """ + Load fixtures for the module + """ self.exec_command.return_value = (0, load_fixture('nios_result.txt').strip(), None) self.load_config.return_value = dict(diff=None, session='session') @@ -84,10 +87,11 @@ def test_nios_dns_view_update_comment(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'ansible-dns', 'comment': 'updated comment', 'extattrs': None} + ref = "dnsview/ZG5zLm5ldHdvcmtfdmlldyQw:ansible/true" test_object = [ { "comment": "test comment", - "_ref": "dnsview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "name": "ansible-dns", "extattrs": {} } @@ -103,6 +107,7 @@ def test_nios_dns_view_update_comment(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with(ref, {'comment': 'updated comment', 'name': 'ansible-dns'}) def test_nios_dns_view_remove(self): self.module.params = {'provider': None, 'state': 'absent', 'name': 'ansible-dns', diff --git a/tests/unit/plugins/modules/test_nios_dtc_monitor_http.py b/tests/unit/plugins/modules/test_nios_dtc_monitor_http.py index d053f0bf..037ea92b 100644 --- a/tests/unit/plugins/modules/test_nios_dtc_monitor_http.py +++ b/tests/unit/plugins/modules/test_nios_dtc_monitor_http.py @@ -84,10 +84,11 @@ def test_nios_dtc_monitor_http_update_comment(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'https_monitor', 'comment': 'updated comment', 'extattrs': None} + ref = "dtc:monitor:http/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "dtc:monitor:http/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "name": "https_monitor", "port": 443, "secure": True, @@ -105,6 +106,7 @@ def test_nios_dtc_monitor_http_update_comment(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with(ref, {'comment': 'updated comment', 'name': 'https_monitor'}) def test_nios_dtc_monitor_http_remove(self): self.module.params = {'provider': None, 'state': 'absent', 'name': 'https_monitor', diff --git a/tests/unit/plugins/modules/test_nios_dtc_monitor_icmp.py b/tests/unit/plugins/modules/test_nios_dtc_monitor_icmp.py index fb4b300d..78f13365 100644 --- a/tests/unit/plugins/modules/test_nios_dtc_monitor_icmp.py +++ b/tests/unit/plugins/modules/test_nios_dtc_monitor_icmp.py @@ -81,10 +81,11 @@ def test_nios_dtc_monitor_icmp_update_comment(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'icmp_monitor', 'comment': 'updated comment', 'extattrs': None} + ref = "dtc:monitor:icmp/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "dtc:monitor:icmp/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "name": "icmp_monitor", "extattrs": {} } @@ -100,6 +101,7 @@ def test_nios_dtc_monitor_icmp_update_comment(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with(ref, {'comment': 'updated comment', 'name': 'icmp_monitor'}) def test_nios_dtc_monitor_icmp_remove(self): self.module.params = {'provider': None, 'state': 'absent', 'name': 'icmp_monitor', diff --git a/tests/unit/plugins/modules/test_nios_dtc_monitor_pdp.py b/tests/unit/plugins/modules/test_nios_dtc_monitor_pdp.py index 80263784..0fb63682 100644 --- a/tests/unit/plugins/modules/test_nios_dtc_monitor_pdp.py +++ b/tests/unit/plugins/modules/test_nios_dtc_monitor_pdp.py @@ -81,10 +81,11 @@ def test_nios_dtc_monitor_pdp_update_comment(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'pdp_monitor', 'comment': 'updated comment', 'extattrs': None} + ref = "dtc:monitor:pdp/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "dtc:monitor:pdp/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "name": "pdp_monitor", "port": 2123, "extattrs": {} @@ -101,6 +102,7 @@ def test_nios_dtc_monitor_pdp_update_comment(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with(ref, {'comment': 'updated comment', 'name': 'pdp_monitor'}) def test_nios_dtc_monitor_pdp_remove(self): self.module.params = {'provider': None, 'state': 'absent', 'name': 'pdp_monitor', diff --git a/tests/unit/plugins/modules/test_nios_dtc_monitor_sip.py b/tests/unit/plugins/modules/test_nios_dtc_monitor_sip.py index 90b86bfa..6e170d75 100644 --- a/tests/unit/plugins/modules/test_nios_dtc_monitor_sip.py +++ b/tests/unit/plugins/modules/test_nios_dtc_monitor_sip.py @@ -80,11 +80,11 @@ def test_nios_dtc_monitor_sip_create(self): def test_nios_dtc_monitor_sip_update_comment(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'sip_monitor', 'comment': 'updated comment', 'extattrs': None} - + ref = "dtc:monitor:sip/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "dtc:monitor:sip/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "name": "sip_monitor", "extattrs": {} } @@ -100,6 +100,7 @@ def test_nios_dtc_monitor_sip_update_comment(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with(ref, {'comment': 'updated comment', 'name': 'sip_monitor'}) def test_nios_dtc_monitor_sip_remove(self): self.module.params = {'provider': None, 'state': 'absent', 'name': 'sip_monitor', diff --git a/tests/unit/plugins/modules/test_nios_dtc_monitor_snmp.py b/tests/unit/plugins/modules/test_nios_dtc_monitor_snmp.py index 838a35eb..374b5a67 100644 --- a/tests/unit/plugins/modules/test_nios_dtc_monitor_snmp.py +++ b/tests/unit/plugins/modules/test_nios_dtc_monitor_snmp.py @@ -80,11 +80,11 @@ def test_nios_dtc_monitor_snmp_create(self): def test_nios_dtc_monitor_snmp_update_comment(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'snmp_monitor', 'comment': 'updated comment', 'extattrs': None} - + ref = "dtc:monitor:snmp/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "dtc:monitor:snmp/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "name": "snmp_monitor", "port": 161, "version": "V2C", @@ -107,6 +107,7 @@ def test_nios_dtc_monitor_snmp_update_comment(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with(ref, {'comment': 'updated comment', 'name': 'snmp_monitor'}) def test_nios_dtc_monitor_snmp_remove(self): self.module.params = {'provider': None, 'state': 'absent', 'name': 'snmp_monitor', diff --git a/tests/unit/plugins/modules/test_nios_dtc_monitor_tcp.py b/tests/unit/plugins/modules/test_nios_dtc_monitor_tcp.py index 072ba1a3..8de3d25f 100644 --- a/tests/unit/plugins/modules/test_nios_dtc_monitor_tcp.py +++ b/tests/unit/plugins/modules/test_nios_dtc_monitor_tcp.py @@ -83,10 +83,11 @@ def test_nios_dtc_monitor_tcp_update_comment(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'tcp_monitor', 'comment': 'updated comment', 'extattrs': None} + ref = "dtc:monitor:tcp/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "dtc:monitor:tcp/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "name": "tcp_monitor", "port": 8080, "extattrs": {} @@ -103,6 +104,7 @@ def test_nios_dtc_monitor_tcp_update_comment(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with(ref, {'comment': 'updated comment', 'name': 'tcp_monitor'}) def test_nios_dtc_monitor_tcp_remove(self): self.module.params = {'provider': None, 'state': 'absent', 'name': 'tcp_monitor', diff --git a/tests/unit/plugins/modules/test_nios_dtc_topology.py b/tests/unit/plugins/modules/test_nios_dtc_topology.py index d0ee4c69..6a11515b 100644 --- a/tests/unit/plugins/modules/test_nios_dtc_topology.py +++ b/tests/unit/plugins/modules/test_nios_dtc_topology.py @@ -101,10 +101,10 @@ def test_nios_dtc_topology_create(self): def test_nios_dtc_topology_update_comment(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'a_topology', 'comment': 'updated comment', 'extattrs': None} - + ref = "dtc:topology/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { - '_ref': 'dtc:topology/ZG5zLm5ldHdvcmtfdmlldyQw:default/true', + '_ref': ref, 'name': 'a_topology', 'rules': [{ '_ref': 'dtc:topology:rule/ZG5zLm5ldHdvcmtfdmlldyQw:a_topology/web_pool' @@ -124,6 +124,7 @@ def test_nios_dtc_topology_update_comment(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with(ref, {'comment': 'updated comment', 'name': 'a_topology'}) def test_nios_dtc_topology_remove(self): self.module.params = {'provider': None, 'state': 'absent', 'name': 'a_topology', diff --git a/tests/unit/plugins/modules/test_nios_fixed_address.py b/tests/unit/plugins/modules/test_nios_fixed_address.py index ae373fd3..ba435b76 100644 --- a/tests/unit/plugins/modules/test_nios_fixed_address.py +++ b/tests/unit/plugins/modules/test_nios_fixed_address.py @@ -82,11 +82,12 @@ def test_nios_fixed_address_ipv4_dhcp_update(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'test_fa', 'ipaddr': '192.168.10.1', 'mac': '08:6d:41:e8:fd:e8', 'network': '192.168.10.0/24', 'network_view': 'default', 'comment': 'updated comment', 'extattrs': None} + ref = "network/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", "name": "test_fa", - "_ref": "network/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "ipaddr": "192.168.10.1", "mac": "08:6d:41:e8:fd:e8", "network": "192.168.10.0/24", @@ -109,6 +110,16 @@ def test_nios_fixed_address_ipv4_dhcp_update(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with( + ref, + { + 'comment': 'updated comment', + 'name': 'test_fa', + 'ipaddr': '192.168.10.1', + 'mac': '08:6d:41:e8:fd:e8', + 'network': '192.168.10.0/24', + } + ) def test_nios_fixed_address_ipv4_remove(self): self.module.params = {'provider': None, 'state': 'absent', 'name': 'test_fa', 'ipaddr': '192.168.10.1', 'mac': '08:6d:41:e8:fd:e8', diff --git a/tests/unit/plugins/modules/test_nios_host_record.py b/tests/unit/plugins/modules/test_nios_host_record.py index 6dc292ec..7bc72337 100644 --- a/tests/unit/plugins/modules/test_nios_host_record.py +++ b/tests/unit/plugins/modules/test_nios_host_record.py @@ -107,10 +107,11 @@ def test_nios_host_record_update_comment(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'default', 'comment': 'updated comment', 'extattrs': None} + ref = "record:host/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "record:host/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "name": "default", "extattrs": {} } @@ -126,18 +127,20 @@ def test_nios_host_record_update_comment(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) - wapi.update_object.assert_called_once_with(test_object) + wapi.update_object.assert_called_once_with( + ref, {'comment': 'updated comment', 'name': 'default'} + ) def test_nios_host_record_update_record_name(self): self.module.params = {'provider': None, 'state': 'present', 'name': {'new_name': 'default', 'old_name': 'old_default'}, 'comment': 'comment', 'extattrs': None} + ref = "record:host/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "record:host/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", - "name": "default", - "old_name": "old_default", + "_ref": ref, + "name": "old_default", "extattrs": {} } ] @@ -152,4 +155,6 @@ def test_nios_host_record_update_record_name(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) - wapi.update_object.assert_called_once_with(test_object) + wapi.update_object.assert_called_once_with( + ref, {'comment': 'comment', 'name': 'default'} + ) diff --git a/tests/unit/plugins/modules/test_nios_member.py b/tests/unit/plugins/modules/test_nios_member.py index a65b5df1..c8e02ce0 100644 --- a/tests/unit/plugins/modules/test_nios_member.py +++ b/tests/unit/plugins/modules/test_nios_member.py @@ -84,11 +84,11 @@ def test_nios_member_update(self): self.module.params = {'provider': None, 'state': 'present', 'host_name': 'test_member', 'vip_setting': {'address': '192.168.1.110', 'subnet_mask': '255.255.255.0', 'gateway': '192.168.1.1'}, 'config_addr_type': 'IPV4', 'platform': 'VNIOS', 'comment': 'updated comment', 'extattrs': None} - + ref = "member/b25lLnZpcnR1YWxfbm9kZSQ3:member01.ansible-dev.com" test_object = [ { "comment": "Created with Ansible", - "_ref": "member/b25lLnZpcnR1YWxfbm9kZSQ3:member01.ansible-dev.com", + "_ref": ref, "config_addr_type": "IPV4", "host_name": "member01.ansible-dev.com", "platform": "VNIOS", @@ -118,6 +118,12 @@ def test_nios_member_update(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with( + ref, + {'comment': 'updated comment', 'host_name': 'test_member', + 'vip_setting': {'address': '192.168.1.110', 'subnet_mask': '255.255.255.0', 'gateway': '192.168.1.1'}, + 'config_addr_type': 'IPV4', 'platform': 'VNIOS'} + ) def test_nios_member_remove(self): self.module.params = {'provider': None, 'state': 'absent', 'host_name': 'test_member', diff --git a/tests/unit/plugins/modules/test_nios_mx_record.py b/tests/unit/plugins/modules/test_nios_mx_record.py index 55524b4d..7f8db39e 100644 --- a/tests/unit/plugins/modules/test_nios_mx_record.py +++ b/tests/unit/plugins/modules/test_nios_mx_record.py @@ -86,11 +86,11 @@ def test_nios_mx_record_create(self): def test_nios_mx_record_update_comment(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'ansible.com', 'mx': 'mailhost.ansible.com', 'preference': 0, 'comment': 'updated comment', 'extattrs': None} - + ref = "mxrecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "mxrecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "name": "ansible.com", "mx": "mailhost.ansible.com", "preference": 0, @@ -110,6 +110,8 @@ def test_nios_mx_record_update_comment(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with(ref, {'comment': 'updated comment', 'name': 'ansible.com', + 'mx': 'mailhost.ansible.com', 'preference': 0}) def test_nios_mx_record_remove(self): self.module.params = {'provider': None, 'state': 'absent', 'name': 'ansible.com', 'mx': 'mailhost.ansible.com', diff --git a/tests/unit/plugins/modules/test_nios_naptr_record.py b/tests/unit/plugins/modules/test_nios_naptr_record.py index 44c9c349..38c3f059 100644 --- a/tests/unit/plugins/modules/test_nios_naptr_record.py +++ b/tests/unit/plugins/modules/test_nios_naptr_record.py @@ -91,10 +91,11 @@ def test_nios_naptr_record_update_comment(self): 'order': '1000', 'preference': '10', 'replacement': 'replacement1.network.ansiblezone.com', 'comment': 'updated comment', 'extattrs': None} + ref = "naptrrecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "naptrrecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "name": "*.subscriber-100.ansiblezone.com", "order": "1000", "preference": "10", @@ -116,6 +117,8 @@ def test_nios_naptr_record_update_comment(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with(ref, {'comment': 'updated comment', 'name': '*.subscriber-100.ansiblezone.com', + 'order': '1000', 'preference': '10', 'replacement': 'replacement1.network.ansiblezone.com'}) def test_nios_naptr_record_remove(self): self.module.params = {'provider': None, 'state': 'absent', 'name': '*.subscriber-100.ansiblezone.com', diff --git a/tests/unit/plugins/modules/test_nios_network.py b/tests/unit/plugins/modules/test_nios_network.py index 0fad5aaa..afc96330 100644 --- a/tests/unit/plugins/modules/test_nios_network.py +++ b/tests/unit/plugins/modules/test_nios_network.py @@ -78,10 +78,11 @@ def test_nios_network_ipv4_dhcp_update(self): self.module.params = {'provider': None, 'state': 'present', 'network': '192.168.10.0/24', 'comment': 'updated comment', 'extattrs': None} + ref = "network/ZG5zLm5ldHdvcmtfdmlldyQw:ansible/true" test_object = [ { "comment": "test comment", - "_ref": "network/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "network": "192.168.10.0/24", "extattrs": {'options': {'name': 'test', 'value': 'ansible.com'}} } @@ -97,15 +98,17 @@ def test_nios_network_ipv4_dhcp_update(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with(ref, {'comment': 'updated comment', 'network': '192.168.10.0/24'}) def test_nios_network_ipv6_dhcp_update(self): self.module.params = {'provider': None, 'state': 'present', 'ipv6network': 'fe80::/64', 'comment': 'updated comment', 'extattrs': None} + ref = "ipv6network/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "ipv6network/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "ipv6network": "fe80::/64", "extattrs": {'options': {'name': 'test', 'value': 'ansible.com'}} } @@ -120,6 +123,7 @@ def test_nios_network_ipv6_dhcp_update(self): wapi = self._get_wapi(test_object) res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with(ref, {'comment': 'updated comment', 'ipv6network': 'fe80::/64'}) def test_nios_network_ipv4_remove(self): self.module.params = {'provider': None, 'state': 'absent', 'network': '192.168.10.0/24', diff --git a/tests/unit/plugins/modules/test_nios_network_view.py b/tests/unit/plugins/modules/test_nios_network_view.py index b768297e..24ee5fbd 100644 --- a/tests/unit/plugins/modules/test_nios_network_view.py +++ b/tests/unit/plugins/modules/test_nios_network_view.py @@ -83,11 +83,11 @@ def test_nios_network_view_create(self): def test_nios_network_view_update_comment(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'default', 'comment': 'updated comment', 'extattrs': None, 'network_view': 'default'} - + ref = "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "name": "default", "extattrs": {}, "network_view": "default" @@ -104,18 +104,20 @@ def test_nios_network_view_update_comment(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) - wapi.update_object.assert_called_once_with(test_object) + wapi.update_object.assert_called_once_with( + ref, + {'comment': 'updated comment', 'name': 'default'} + ) def test_nios_network_view_update_name(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'default', 'old_name': 'old_default', 'comment': 'updated comment', 'extattrs': None, 'network_view': 'default'} - + ref = "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", - "name": "default", - "old_name": "old_default", + "_ref": ref, + "name": "old_default", "extattrs": {}, "network_view": "default" } @@ -131,7 +133,10 @@ def test_nios_network_view_update_name(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) - wapi.update_object.assert_called_once_with(test_object) + wapi.update_object.assert_called_once_with( + ref, + {'comment': 'updated comment', 'name': 'default'} + ) def test_nios_network_view_remove(self): self.module.params = {'provider': None, 'state': 'absent', 'name': 'ansible', diff --git a/tests/unit/plugins/modules/test_nios_nsgroup.py b/tests/unit/plugins/modules/test_nios_nsgroup.py index a99c6ec1..195ea7a7 100644 --- a/tests/unit/plugins/modules/test_nios_nsgroup.py +++ b/tests/unit/plugins/modules/test_nios_nsgroup.py @@ -107,10 +107,11 @@ def test_nios_nsgroup_update_comment(self): self.module.params = {'provider': None, 'state': 'present', 'name': 'default', 'comment': 'updated comment', 'grid_primary': None} + ref = "nsgroup/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "nsgroup/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "name": "default", "grid_primary": {} } @@ -126,4 +127,6 @@ def test_nios_nsgroup_update_comment(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) - wapi.update_object.assert_called_once_with(test_object) + wapi.update_object.assert_called_once_with( + ref, {'comment': 'updated comment', 'name': 'default'} + ) diff --git a/tests/unit/plugins/modules/test_nios_ptr_record.py b/tests/unit/plugins/modules/test_nios_ptr_record.py index 67a9d5d8..68f69b9c 100644 --- a/tests/unit/plugins/modules/test_nios_ptr_record.py +++ b/tests/unit/plugins/modules/test_nios_ptr_record.py @@ -109,11 +109,11 @@ def test_nios_ptr_record_remove(self): def test_nios_ptr_record_update_comment(self): self.module.params = {'provider': None, 'state': 'present', 'ptrdname': 'ansible.test.com', 'ipv4addr': '10.36.241.14', 'comment': 'updated comment', 'extattrs': None, 'view': 'default'} - + ref = "record:ptr/ZG5zLm5ldHdvcmtfdmlldyQw:14.241.36.10.in-addr.arpa/default" test_object = [ { "comment": "test comment", - "_ref": "record:ptr/ZG5zLm5ldHdvcmtfdmlldyQw:14.241.36.10.in-addr.arpa/default", + "_ref": ref, "ptrdname": "ansible.test.com", "ipv4addr": "10.36.241.14", "extattrs": {}, @@ -133,16 +133,18 @@ def test_nios_ptr_record_update_comment(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) - wapi.update_object.assert_called_once_with(test_object) + wapi.update_object.assert_called_once_with( + ref, {'comment': 'updated comment', 'ptrdname': 'ansible.test.com', 'ipv4addr': '10.36.241.14', 'view': 'default'} + ) def test_nios_ptr_record_update_record_ptrdname(self): self.module.params = {'provider': None, 'state': 'present', 'ptrdname': 'ansible.test.org', 'ipv4addr': '10.36.241.14', 'comment': 'comment', 'extattrs': None, 'view': 'default'} - + ref = "record:ptr/ZG5zLm5ldHdvcmtfdmlldyQw:14.241.36.10.in-addr.arpa/default" test_object = [ { "comment": "test comment", - "_ref": "record:ptr/ZG5zLm5ldHdvcmtfdmlldyQw:14.241.36.10.in-addr.arpa/default", + "_ref": ref, "ptrdname": "ansible.test.com", "ipv4addr": "10.36.241.14", "extattrs": {}, @@ -162,7 +164,9 @@ def test_nios_ptr_record_update_record_ptrdname(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) - wapi.update_object.assert_called_once_with(test_object) + wapi.update_object.assert_called_once_with( + ref, {'comment': 'comment', 'ptrdname': 'ansible.test.org', 'ipv4addr': '10.36.241.14', 'view': 'default'} + ) def test_nios_ptr6_record_create(self): self.module.params = {'provider': None, 'state': 'present', 'ptrdname': 'ansible6.test.com', diff --git a/tests/unit/plugins/modules/test_nios_srv_record.py b/tests/unit/plugins/modules/test_nios_srv_record.py index 9a6f3fb3..5c41cd4c 100644 --- a/tests/unit/plugins/modules/test_nios_srv_record.py +++ b/tests/unit/plugins/modules/test_nios_srv_record.py @@ -90,11 +90,11 @@ def test_nios_srv_record_update_comment(self): self.module.params = {'provider': None, 'state': 'present', 'name': '_sip._tcp.service.ansible.com', 'port': 5080, 'target': 'service1.ansible.com', 'priority': 10, 'weight': 10, 'comment': None, 'extattrs': None} - + ref = "srvrecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "srvrecord/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "name": "_sip._tcp.service.ansible.com", 'port': 5080, "target": "mailhost.ansible.com", @@ -118,6 +118,8 @@ def test_nios_srv_record_update_comment(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with(ref, {'name': '_sip._tcp.service.ansible.com', + 'port': 5080, 'target': 'service1.ansible.com', 'priority': 10, 'weight': 10}) def test_nios_srv_record_remove(self): self.module.params = {'provider': None, 'state': 'absent', 'name': '_sip._tcp.service.ansible.com', diff --git a/tests/unit/plugins/modules/test_nios_zone.py b/tests/unit/plugins/modules/test_nios_zone.py index 693ab060..20230c8e 100644 --- a/tests/unit/plugins/modules/test_nios_zone.py +++ b/tests/unit/plugins/modules/test_nios_zone.py @@ -104,11 +104,11 @@ def test_nios_zone_remove(self): def test_nios_zone_update_comment(self): self.module.params = {'provider': None, 'state': 'present', 'fqdn': 'ansible.com', 'comment': 'updated comment', 'extattrs': None} - + ref = "zone/ZG5zLm5ldHdvcmtfdmlldyQw:default/true" test_object = [ { "comment": "test comment", - "_ref": "zone/ZG5zLm5ldHdvcmtfdmlldyQw:default/true", + "_ref": ref, "fqdn": "ansible.com", "extattrs": {'Site': {'value': 'test'}} } @@ -124,6 +124,7 @@ def test_nios_zone_update_comment(self): res = wapi.run('testobject', test_spec) self.assertTrue(res['changed']) + wapi.update_object.assert_called_once_with(ref, {'comment': 'updated comment', 'fqdn': 'ansible.com'}) def test_nios_zone_create_using_grid_primary_secondaries(self): self.module.params = {'provider': None, 'state': 'present', 'fqdn': 'ansible.com', diff --git a/tests/unit/requirements.txt b/tests/unit/requirements.txt index e2aefbb4..c64045e9 100644 --- a/tests/unit/requirements.txt +++ b/tests/unit/requirements.txt @@ -5,5 +5,4 @@ pytest-xdist mock pytest-mock pytest-cov -coverage - +coverage==7.3.2