def test_vx_run_list_twice(self): # gymnastics for ansible stdin = sys.stdin argv = sys.argv sys.argv = [] sys.stdin = StringIO.StringIO('{"ANSIBLE_MODULE_ARGS": {}}') # start by doing some cleanup module = AnsibleModule(argument_spec=dict()) nclu.command_helper(module, 'abort') nclu.command_helper(module, 'del interface swp1') nclu.command_helper(module, 'commit') nclu.command_helper(module, 'abort') # run the test changed, output = nclu.run_nclu(module, ['add int swp1'], None, False, True, False, "atomically") self.assertEqual(changed, True) changed, output = nclu.run_nclu(module, ['add int swp1'], None, False, True, False, "atomically") self.assertEqual(changed, False) # gymnastics to fix ansible sys.stdin = stdin sys.argv = argv
def test_command_helper_no_error_msg(self): module = FakeModule() module.mock_output("/usr/bin/net fake fail command", 0, "ERROR: Command not found", "") result = nclu.command_helper(module, 'fake fail command') self.assertEqual(module.fail_code, {'msg': "ERROR: Command not found"})
def test_command_helper(self): module = FakeModule() module.mock_output("/usr/bin/net add int swp1", 0, "", "") result = nclu.command_helper(module, 'add int swp1', 'error out') self.assertEqual(module.command_history[-1], "/usr/bin/net add int swp1") self.assertEqual(result, "")
def test_vx_command_helper(self): # gymnastics for ansible stdin = sys.stdin argv = sys.argv sys.argv = [] sys.stdin = StringIO.StringIO('{"ANSIBLE_MODULE_ARGS": {}}') # test module = AnsibleModule(argument_spec=dict()) nclu.command_helper(module, 'abort') nclu.command_helper(module, 'del interface swp1') nclu.command_helper(module, 'commit') nclu.command_helper(module, 'abort') # gymnastics to fix ansible sys.stdin = stdin sys.argv = argv
def test_command_helper_error_code(self): module = FakeModule() module.mock_output("/usr/bin/net fake fail command", 1, "", "") result = nclu.command_helper(module, 'fake fail command', 'error out') self.assertEqual(module.fail_code, {'msg': "error out"})
def test_vx_show_pending(self): # gymnastics for ansible stdin = sys.stdin argv = sys.argv sys.argv = [] sys.stdin = StringIO.StringIO('{"ANSIBLE_MODULE_ARGS": {}}') # start by doing some cleanup module = AnsibleModule(argument_spec=dict()) nclu.command_helper(module, 'abort') nclu.command_helper(module, 'del interface swp1') nclu.command_helper(module, 'commit') nclu.command_helper(module, 'abort') # nclu.command_helper(module, 'add interface swp1') pending = nclu.check_pending(module) self.assertTrue('swp1' in pending) nclu.command_helper(module, 'abort') pending = nclu.check_pending(module) self.assertTrue('swp1' not in pending) # gymnastics to fix ansible sys.stdin = stdin sys.argv = argv