|
|
|
@ -31,7 +31,6 @@ from units.mock.loader import DictDataLoader
|
|
|
|
|
|
|
|
|
|
class TestNetworkFacts(unittest.TestCase):
|
|
|
|
|
task = MagicMock(Task)
|
|
|
|
|
task_vars = {'ansible_network_os': 'ios'}
|
|
|
|
|
play_context = MagicMock()
|
|
|
|
|
play_context.check_mode = False
|
|
|
|
|
connection = MagicMock()
|
|
|
|
@ -46,6 +45,7 @@ class TestNetworkFacts(unittest.TestCase):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def test_network_gather_facts(self):
|
|
|
|
|
self.task_vars = {'ansible_network_os': 'ios'}
|
|
|
|
|
self.task.action = 'gather_facts'
|
|
|
|
|
self.task.async_val = False
|
|
|
|
|
self.task.args = {'gather_subset': 'min'}
|
|
|
|
@ -62,3 +62,22 @@ class TestNetworkFacts(unittest.TestCase):
|
|
|
|
|
|
|
|
|
|
facts_modules = C.config.get_config_value('FACTS_MODULES', variables=self.task_vars)
|
|
|
|
|
self.assertEqual(facts_modules, ['ios_facts'])
|
|
|
|
|
|
|
|
|
|
def test_network_gather_facts_fqcn(self):
|
|
|
|
|
self.fqcn_task_vars = {'ansible_network_os': 'cisco.ios.ios'}
|
|
|
|
|
self.task.action = 'gather_facts'
|
|
|
|
|
self.task.async_val = False
|
|
|
|
|
self.task.args = {'gather_subset': 'min'}
|
|
|
|
|
self.task.module_defaults = [{'cisco.ios.ios_facts': {'gather_subset': 'min'}}]
|
|
|
|
|
|
|
|
|
|
plugin = ActionModule(self.task, self.connection, self.play_context, loader=None, templar=self.templar, shared_loader_obj=None)
|
|
|
|
|
plugin._execute_module = MagicMock()
|
|
|
|
|
|
|
|
|
|
res = plugin.run(task_vars=self.fqcn_task_vars)
|
|
|
|
|
self.assertEqual(res['ansible_facts']['_ansible_facts_gathered'], True)
|
|
|
|
|
|
|
|
|
|
mod_args = plugin._get_module_args('cisco.ios.ios_facts', task_vars=self.fqcn_task_vars)
|
|
|
|
|
self.assertEqual(mod_args['gather_subset'], 'min')
|
|
|
|
|
|
|
|
|
|
facts_modules = C.config.get_config_value('FACTS_MODULES', variables=self.fqcn_task_vars)
|
|
|
|
|
self.assertEqual(facts_modules, ['cisco.ios.ios_facts'])
|
|
|
|
|