def test_module_args(self, mock_module, mock_client): """ hpe3par flash cache - test module arguments """ mock_module.params = self.PARAMS_FOR_PRESENT mock_module.return_value = mock_module host.main() mock_module.assert_called_with(argument_spec=self.fields)
def test_main_exit_functionality_success_without_issue_attr_dict_modify( self, mock_host, mock_module, mock_client): """ hpe3par host - success check """ # This creates a instance of the AnsibleModule mock. mock_module.params = self.PARAMS_FOR_PRESENT mock_module.params["state"] = "modify" mock_module.return_value = mock_module instance = mock_module.return_value host.main() # AnsibleModule.exit_json should be called instance.exit_json.assert_called_with( changed=True, msg="Modified host host successfully.")
def test_main_exit_functionality_success_without_issue_attr_dict_remove_initiator_chap( self, mock_add_initiator_chap, mock_module, mock_client): """ hpe3par host - success check """ # This creates a instance of the AnsibleModule mock. mock_module.params = self.PARAMS_FOR_PRESENT mock_module.params["state"] = "remove_initiator_chap" mock_module.return_value = mock_module instance = mock_module.return_value mock_add_initiator_chap.return_value = ( True, True, "Remove_initiator_chap successfully.", {}) host.main() # AnsibleModule.exit_json should be called instance.exit_json.assert_called_with( changed=True, msg="Remove_initiator_chap successfully.")
def test_main_exit_functionality_fail(self, mock_host, mock_module, mock_client): """ hpe3par host - exit fail check """ # This creates a instance of the AnsibleModule mock. mock_module.params = self.PARAMS_FOR_PRESENT mock_module.return_value = mock_module instance = mock_module.return_value mock_host.return_value = (False, False, "Host creation failed.", { "dummy": "dummy" }) host.main() # AnsibleModule.exit_json should not be activated self.assertEqual(instance.exit_json.call_count, 0) # AnsibleModule.fail_json should be called instance.fail_json.assert_called_with(msg='Host creation failed.')