Fix nios modules to work with ansible-core 2.11 (#2057)

* Fix nios modules to work with ansible-core 2.11.

* Adjust tests.
This commit is contained in:
Felix Fontein 2021-03-20 13:45:42 +01:00 committed by GitHub
commit 24f8be834a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 59 additions and 22 deletions

View file

@ -40,11 +40,14 @@ class TestNiosARecordModule(TestNiosModule):
self.mock_wapi_run = patch('ansible_collections.community.general.plugins.modules.net_tools.nios.nios_a_record.WapiModule.run')
self.mock_wapi_run.start()
self.load_config = self.mock_wapi_run.start()
self.mock_check_type_dict = patch('ansible_collections.community.general.plugins.module_utils.net_tools.nios.api.check_type_dict')
self.mock_check_type_dict_obj = self.mock_check_type_dict.start()
def tearDown(self):
super(TestNiosARecordModule, self).tearDown()
self.mock_wapi.stop()
self.mock_wapi_run.stop()
self.mock_check_type_dict.stop()
def _get_wapi(self, test_object):
wapi = api.WapiModule(self.module)
@ -76,7 +79,7 @@ class TestNiosARecordModule(TestNiosModule):
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.create_object.assert_called_once_with('testobject', {'name': self.module._check_type_dict().__getitem__(),
wapi.create_object.assert_called_once_with('testobject', {'name': self.mock_check_type_dict_obj().__getitem__(),
'ipv4': '192.168.10.1'})
def test_nios_a_record_update_comment(self):

View file

@ -40,11 +40,14 @@ class TestNiosAAAARecordModule(TestNiosModule):
self.mock_wapi_run = patch('ansible_collections.community.general.plugins.modules.net_tools.nios.nios_aaaa_record.WapiModule.run')
self.mock_wapi_run.start()
self.load_config = self.mock_wapi_run.start()
self.mock_check_type_dict = patch('ansible_collections.community.general.plugins.module_utils.net_tools.nios.api.check_type_dict')
self.mock_check_type_dict_obj = self.mock_check_type_dict.start()
def tearDown(self):
super(TestNiosAAAARecordModule, self).tearDown()
self.mock_wapi.stop()
self.mock_wapi_run.stop()
self.mock_check_type_dict.stop()
def _get_wapi(self, test_object):
wapi = api.WapiModule(self.module)
@ -76,7 +79,7 @@ class TestNiosAAAARecordModule(TestNiosModule):
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.create_object.assert_called_once_with('testobject', {'name': self.module._check_type_dict().__getitem__(),
wapi.create_object.assert_called_once_with('testobject', {'name': self.mock_check_type_dict_obj().__getitem__(),
'ipv6': '2001:0db8:85a3:0000:0000:8a2e:0370:7334'})
def test_nios_aaaa_record_update_comment(self):

View file

@ -40,11 +40,14 @@ class TestNiosCNameRecordModule(TestNiosModule):
self.mock_wapi_run = patch('ansible_collections.community.general.plugins.modules.net_tools.nios.nios_cname_record.WapiModule.run')
self.mock_wapi_run.start()
self.load_config = self.mock_wapi_run.start()
self.mock_check_type_dict = patch('ansible_collections.community.general.plugins.module_utils.net_tools.nios.api.check_type_dict')
self.mock_check_type_dict_obj = self.mock_check_type_dict.start()
def tearDown(self):
super(TestNiosCNameRecordModule, self).tearDown()
self.mock_wapi.stop()
self.mock_wapi_run.stop()
self.mock_check_type_dict.stop()
def _get_wapi(self, test_object):
wapi = api.WapiModule(self.module)
@ -76,7 +79,7 @@ class TestNiosCNameRecordModule(TestNiosModule):
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.create_object.assert_called_once_with('testobject', {'name': self.module._check_type_dict().__getitem__(),
wapi.create_object.assert_called_once_with('testobject', {'name': self.mock_check_type_dict_obj().__getitem__(),
'canonical': 'realhost.ansible.com'})
def test_nios_a_record_update_comment(self):

View file

@ -40,11 +40,14 @@ class TestNiosDnsViewModule(TestNiosModule):
self.mock_wapi_run = patch('ansible_collections.community.general.plugins.modules.net_tools.nios.nios_dns_view.WapiModule.run')
self.mock_wapi_run.start()
self.load_config = self.mock_wapi_run.start()
self.mock_check_type_dict = patch('ansible_collections.community.general.plugins.module_utils.net_tools.nios.api.check_type_dict')
self.mock_check_type_dict_obj = self.mock_check_type_dict.start()
def tearDown(self):
super(TestNiosDnsViewModule, self).tearDown()
self.mock_wapi.stop()
self.mock_wapi_run.stop()
self.mock_check_type_dict.stop()
def _get_wapi(self, test_object):
wapi = api.WapiModule(self.module)
@ -75,7 +78,7 @@ class TestNiosDnsViewModule(TestNiosModule):
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.create_object.assert_called_once_with('testobject', {'name': self.module._check_type_dict().__getitem__()})
wapi.create_object.assert_called_once_with('testobject', {'name': self.mock_check_type_dict_obj().__getitem__()})
def test_nios_dns_view_update_comment(self):
self.module.params = {'provider': None, 'state': 'present', 'name': 'ansible-dns',

View file

@ -41,10 +41,13 @@ class TestNiosHostRecordModule(TestNiosModule):
self.mock_wapi_run.start()
self.load_config = self.mock_wapi_run.start()
self.mock_check_type_dict = patch('ansible_collections.community.general.plugins.module_utils.net_tools.nios.api.check_type_dict')
self.mock_check_type_dict_obj = self.mock_check_type_dict.start()
def tearDown(self):
super(TestNiosHostRecordModule, self).tearDown()
self.mock_wapi.stop()
self.mock_check_type_dict.stop()
def _get_wapi(self, test_object):
wapi = api.WapiModule(self.module)
@ -74,7 +77,7 @@ class TestNiosHostRecordModule(TestNiosModule):
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.create_object.assert_called_once_with('testobject', {'name': self.module._check_type_dict().__getitem__()})
wapi.create_object.assert_called_once_with('testobject', {'name': self.mock_check_type_dict_obj().__getitem__()})
def test_nios_host_record_remove(self):
self.module.params = {'provider': None, 'state': 'absent', 'name': 'ansible',

View file

@ -40,11 +40,14 @@ class TestNiosMXRecordModule(TestNiosModule):
self.mock_wapi_run = patch('ansible_collections.community.general.plugins.modules.net_tools.nios.nios_mx_record.WapiModule.run')
self.mock_wapi_run.start()
self.load_config = self.mock_wapi_run.start()
self.mock_check_type_dict = patch('ansible_collections.community.general.plugins.module_utils.net_tools.nios.api.check_type_dict')
self.mock_check_type_dict_obj = self.mock_check_type_dict.start()
def tearDown(self):
super(TestNiosMXRecordModule, self).tearDown()
self.mock_wapi.stop()
self.mock_wapi_run.stop()
self.mock_check_type_dict.stop()
def _get_wapi(self, test_object):
wapi = api.WapiModule(self.module)
@ -77,7 +80,7 @@ class TestNiosMXRecordModule(TestNiosModule):
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.create_object.assert_called_once_with('testobject', {'name': self.module._check_type_dict().__getitem__(),
wapi.create_object.assert_called_once_with('testobject', {'name': self.mock_check_type_dict_obj().__getitem__(),
'mx': 'mailhost.ansible.com', 'preference': 0})
def test_nios_mx_record_update_comment(self):

View file

@ -40,11 +40,14 @@ class TestNiosNAPTRRecordModule(TestNiosModule):
self.mock_wapi_run = patch('ansible_collections.community.general.plugins.modules.net_tools.nios.nios_naptr_record.WapiModule.run')
self.mock_wapi_run.start()
self.load_config = self.mock_wapi_run.start()
self.mock_check_type_dict = patch('ansible_collections.community.general.plugins.module_utils.net_tools.nios.api.check_type_dict')
self.mock_check_type_dict_obj = self.mock_check_type_dict.start()
def tearDown(self):
super(TestNiosNAPTRRecordModule, self).tearDown()
self.mock_wapi.stop()
self.mock_wapi_run.stop()
self.mock_check_type_dict.stop()
def _get_wapi(self, test_object):
wapi = api.WapiModule(self.module)
@ -79,7 +82,7 @@ class TestNiosNAPTRRecordModule(TestNiosModule):
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.create_object.assert_called_once_with('testobject', {'name': self.module._check_type_dict().__getitem__(),
wapi.create_object.assert_called_once_with('testobject', {'name': self.mock_check_type_dict_obj().__getitem__(),
'order': '1000', 'preference': '10',
'replacement': 'replacement1.network.ansiblezone.com'})

View file

@ -40,11 +40,14 @@ class TestNiosNetworkViewModule(TestNiosModule):
self.mock_wapi_run = patch('ansible_collections.community.general.plugins.modules.net_tools.nios.nios_network_view.WapiModule.run')
self.mock_wapi_run.start()
self.load_config = self.mock_wapi_run.start()
self.mock_check_type_dict = patch('ansible_collections.community.general.plugins.module_utils.net_tools.nios.api.check_type_dict')
self.mock_check_type_dict_obj = self.mock_check_type_dict.start()
def tearDown(self):
super(TestNiosNetworkViewModule, self).tearDown()
self.mock_wapi.stop()
self.mock_wapi_run.stop()
self.mock_check_type_dict.stop()
def _get_wapi(self, test_object):
wapi = api.WapiModule(self.module)
@ -75,7 +78,7 @@ class TestNiosNetworkViewModule(TestNiosModule):
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.create_object.assert_called_once_with('testobject', {'name': self.module._check_type_dict().__getitem__()})
wapi.create_object.assert_called_once_with('testobject', {'name': self.mock_check_type_dict_obj().__getitem__()})
def test_nios_network_view_update_comment(self):
self.module.params = {'provider': None, 'state': 'present', 'name': 'default',

View file

@ -42,9 +42,13 @@ class TestNiosNSGroupModule(TestNiosModule):
self.load_config = self.mock_wapi_run.start()
self.mock_check_type_dict = patch('ansible_collections.community.general.plugins.module_utils.net_tools.nios.api.check_type_dict')
self.mock_check_type_dict_obj = self.mock_check_type_dict.start()
def tearDown(self):
super(TestNiosNSGroupModule, self).tearDown()
self.mock_wapi.stop()
self.mock_check_type_dict.stop()
def _get_wapi(self, test_object):
wapi = api.WapiModule(self.module)
@ -73,7 +77,7 @@ class TestNiosNSGroupModule(TestNiosModule):
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.create_object.assert_called_once_with('testobject', {'name': self.module._check_type_dict().__getitem__()})
wapi.create_object.assert_called_once_with('testobject', {'name': self.mock_check_type_dict_obj().__getitem__()})
def test_nios_nsgroup_remove(self):
self.module.params = {'provider': None, 'state': 'absent', 'name': 'my-simple-group',

View file

@ -40,11 +40,14 @@ class TestNiosSRVRecordModule(TestNiosModule):
self.mock_wapi_run = patch('ansible_collections.community.general.plugins.modules.net_tools.nios.nios_srv_record.WapiModule.run')
self.mock_wapi_run.start()
self.load_config = self.mock_wapi_run.start()
self.mock_check_type_dict = patch('ansible_collections.community.general.plugins.module_utils.net_tools.nios.api.check_type_dict')
self.mock_check_type_dict_obj = self.mock_check_type_dict.start()
def tearDown(self):
super(TestNiosSRVRecordModule, self).tearDown()
self.mock_wapi.stop()
self.mock_wapi_run.stop()
self.mock_check_type_dict.stop()
def _get_wapi(self, test_object):
wapi = api.WapiModule(self.module)
@ -80,7 +83,7 @@ class TestNiosSRVRecordModule(TestNiosModule):
res = wapi.run('testobject', test_spec)
self.assertTrue(res['changed'])
wapi.create_object.assert_called_once_with('testobject', {'name': self.module._check_type_dict().__getitem__(),
wapi.create_object.assert_called_once_with('testobject', {'name': self.mock_check_type_dict_obj().__getitem__(),
'port': 5080, 'target': 'service1.ansible.com', 'priority': 10, 'weight': 10})
def test_nios_srv_record_update_comment(self):