def test_nxos_config_save_changed_true(self): args = dict(save_when='changed', lines=['sysname foo', 'interface create mtc-3 3']) set_module_args(args) self.execute_module(changed=True) self.assertEqual(self.save_config.call_count, 1) self.assertEqual(self.get_config.call_count, 1) self.assertEqual(self.load_config.call_count, 1)
def test_nxos_config_save_changed_false(self): args = dict(save_when='changed') set_module_args(args) self.execute_module() self.assertEqual(self.save_config.call_count, 0) self.assertEqual(self.get_config.call_count, 0) self.assertEqual(self.load_config.call_count, 0)
def test_nxos_config_save_always(self): args = dict(save_when='always') set_module_args(args) self.execute_module() self.assertEqual(self.save_config.call_count, 1) self.assertEqual(self.get_config.call_count, 0) self.assertEqual(self.load_config.call_count, 0)
def test_aireos_command_match_any(self): wait_for = [ 'result[0] contains "Cisco Systems Inc"', 'result[0] contains "test string"' ] set_module_args( dict(commands=['show sysinfo'], wait_for=wait_for, match='any')) self.execute_module()
def test_aireos_command_match_all_failure(self): wait_for = [ 'result[0] contains "Cisco Systems Inc"', 'result[0] contains "test string"' ] commands = ['show sysinfo', 'show sysinfo'] set_module_args(dict(commands=commands, wait_for=wait_for, match='all')) self.execute_module(failed=True)
def test_aireos_config_config(self): config = 'sysname localhost' set_module_args(dict(lines=['sysname router'], config=config)) commands = ['sysname router'] self.execute_module(changed=True, commands=commands)
def test_aireos_config_before_after_no_change(self): set_module_args(dict(lines=['sysname router'], before=['test1', 'test2'], after=['test3', 'test4'])) self.execute_module()
def test_aireos_config_after(self): set_module_args(dict(lines=['sysname foo'], after=['test1', 'test2'])) commands = ['sysname foo', 'test1', 'test2'] self.execute_module(changed=True, commands=commands, sort=False)
def test_aireos_config_save(self): set_module_args(dict(save=True)) self.execute_module() self.assertEqual(self.save_config.call_count, 1) self.assertEqual(self.get_config.call_count, 0) self.assertEqual(self.load_config.call_count, 0)
def test_aireos_config_backup(self): set_module_args(dict(backup=True)) result = self.execute_module() self.assertIn('__backup__', result)
def test_aireos_config_src(self): src = load_fixture('aireos_config_src.cfg') set_module_args(dict(src=src)) commands = ['sysname foo', 'interface address dynamic-interface mtc-1 10.33.20.4 255.255.255.0 10.33.20.2'] self.execute_module(changed=True, commands=commands)
def test_aireos_config_unchanged(self): src = load_fixture('aireos_config_config.cfg') set_module_args(dict(src=src)) self.execute_module()
def test_aireos_config_match_none(self): lines = ['sysname router', 'interface create mtc-1 1'] set_module_args(dict(lines=lines, match='none')) self.execute_module(changed=True, commands=lines, sort=False)
def test_aireos_command_retries(self): wait_for = 'result[0] contains "test string"' set_module_args( dict(commands=['show sysinfo'], wait_for=wait_for, retries=2)) self.execute_module(failed=True) self.assertEqual(self.run_commands.call_count, 2)
def test_aireos_command_wait_for(self): wait_for = 'result[0] contains "Cisco Systems Inc"' set_module_args(dict(commands=['show sysinfo'], wait_for=wait_for)) self.execute_module()
def test_aireos_command_multiple(self): set_module_args(dict(commands=['show sysinfo', 'show sysinfo'])) result = self.execute_module() self.assertEqual(len(result['stdout']), 2) self.assertTrue(result['stdout'][0].startswith('Manufacturer\'s Name'))