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 qos.main() mock_module.assert_called_with(argument_spec=self.fields)
def test_main_exit_functionality_success_without_issue_attr_dict( self, mock_create_qos_rule, mock_module, mock_client): """ hpe3par flash cache - success 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_create_qos_rule.return_value = (True, True, "Created QOS successfully.", {}) qos.main() # AnsibleModule.exit_json should be called instance.exit_json.assert_called_with(changed=True, msg="Created QOS successfully.") # AnsibleModule.fail_json should not be called self.assertEqual(instance.fail_json.call_count, 0)
def test_main_exit_functionality_fail(self, mock_create_qos_rule, mock_module, mock_client): """ hpe3par flash cache - 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_create_qos_rule.return_value = (False, False, "QOS creation failed.", { "dummy": "dummy" }) qos.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='QOS creation failed.')