mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-14 04:09:11 -07:00
* Fix nios modules to work with ansible-core 2.11.
* Adjust tests.
(cherry picked from commit 24f8be834a
)
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
0ca922248f
commit
1f975eff56
13 changed files with 59 additions and 22 deletions
|
@ -22,11 +22,14 @@ class TestNiosApi(unittest.TestCase):
|
|||
|
||||
self.mock_connector = patch('ansible_collections.community.general.plugins.module_utils.net_tools.nios.api.get_connector')
|
||||
self.mock_connector.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(TestNiosApi, self).tearDown()
|
||||
|
||||
self.mock_connector.stop()
|
||||
self.mock_check_type_dict.stop()
|
||||
|
||||
def test_get_provider_spec(self):
|
||||
provider_options = ['host', 'username', 'password', 'validate_certs', 'silent_ssl_warnings',
|
||||
|
@ -55,7 +58,7 @@ class TestNiosApi(unittest.TestCase):
|
|||
{
|
||||
"comment": "test comment",
|
||||
"_ref": "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true",
|
||||
"name": self.module._check_type_dict().__getitem__(),
|
||||
"name": self.mock_check_type_dict_obj().__getitem__(),
|
||||
"extattrs": {}
|
||||
}
|
||||
]
|
||||
|
@ -143,7 +146,7 @@ class TestNiosApi(unittest.TestCase):
|
|||
|
||||
kwargs = copy.deepcopy(test_object[0])
|
||||
kwargs['extattrs']['Site']['value'] = 'update'
|
||||
kwargs['name'] = self.module._check_type_dict().__getitem__()
|
||||
kwargs['name'] = self.mock_check_type_dict_obj().__getitem__()
|
||||
del kwargs['_ref']
|
||||
|
||||
wapi = self._get_wapi(test_object)
|
||||
|
@ -159,7 +162,7 @@ class TestNiosApi(unittest.TestCase):
|
|||
test_object = [{
|
||||
"comment": "test comment",
|
||||
"_ref": "networkview/ZG5zLm5ldHdvcmtfdmlldyQw:default/true",
|
||||
"name": self.module._check_type_dict().__getitem__(),
|
||||
"name": self.mock_check_type_dict_obj().__getitem__(),
|
||||
"extattrs": {'Site': {'value': 'test'}}
|
||||
}]
|
||||
|
||||
|
@ -190,7 +193,7 @@ class TestNiosApi(unittest.TestCase):
|
|||
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_wapi_delete(self):
|
||||
self.module.params = {'provider': None, 'state': 'absent', 'name': 'ansible',
|
||||
|
@ -240,7 +243,7 @@ class TestNiosApi(unittest.TestCase):
|
|||
kwargs = test_object[0].copy()
|
||||
ref = kwargs.pop('_ref')
|
||||
kwargs['comment'] = 'updated comment'
|
||||
kwargs['name'] = self.module._check_type_dict().__getitem__()
|
||||
kwargs['name'] = self.mock_check_type_dict_obj().__getitem__()
|
||||
del kwargs['network_view']
|
||||
del kwargs['extattrs']
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue