Fix network action plugin load in collection (#65849)
* Fix network action plugin load in collection Fixes https://github.com/ansible/ansible/issues/65071 * Load network action plugin that matches the module prefix name from list of collections. * Update changelog * Fix unit test
This commit is contained in:
@ -422,20 +422,21 @@ class TestTaskExecutor(unittest.TestCase):
|
||||
)
|
||||
|
||||
action_loader = te._shared_loader_obj.action_loader
|
||||
action_loader.has_plugin.return_value = False
|
||||
action_loader.has_plugin.side_effect = [False, True]
|
||||
action_loader.get.return_value = mock.sentinel.handler
|
||||
action_loader.__contains__.return_value = True
|
||||
|
||||
mock_connection = MagicMock()
|
||||
mock_templar = MagicMock()
|
||||
action = 'namespace.netconf_sufix'
|
||||
module_prefix = action.split('.')[-1].split('_')[0]
|
||||
te._task.action = action
|
||||
|
||||
handler = te._get_action_handler(mock_connection, mock_templar)
|
||||
|
||||
self.assertIs(mock.sentinel.handler, handler)
|
||||
action_loader.has_plugin.assert_called_once_with(
|
||||
action, collection_list=te._task.collections)
|
||||
action_loader.has_plugin.assert_has_calls([mock.call(action, collection_list=te._task.collections),
|
||||
mock.call(module_prefix, collection_list=te._task.collections)])
|
||||
|
||||
action_loader.get.assert_called_once_with(
|
||||
'netconf', task=te._task, connection=mock_connection,
|
||||
@ -463,13 +464,14 @@ class TestTaskExecutor(unittest.TestCase):
|
||||
mock_connection = MagicMock()
|
||||
mock_templar = MagicMock()
|
||||
action = 'namespace.prefix_sufix'
|
||||
module_prefix = action.split('.')[-1].split('_')[0]
|
||||
te._task.action = action
|
||||
|
||||
handler = te._get_action_handler(mock_connection, mock_templar)
|
||||
|
||||
self.assertIs(mock.sentinel.handler, handler)
|
||||
action_loader.has_plugin.assert_called_once_with(
|
||||
action, collection_list=te._task.collections)
|
||||
|
||||
action_loader.has_plugin.assert_has_calls([mock.call(action, collection_list=te._task.collections),
|
||||
mock.call(module_prefix, collection_list=te._task.collections)])
|
||||
|
||||
action_loader.get.assert_called_once_with(
|
||||
'normal', task=te._task, connection=mock_connection,
|
||||
|
||||
Reference in New Issue
Block a user