示例#1
0
    def test_module_args(self, mock_module, mock_client):
        """
        hpe3par host set - test module arguments
        """

        mock_module.params = self.PARAMS_FOR_PRESENT
        mock_module.return_value = mock_module
        hostset.main()
        mock_module.assert_called_with(
            argument_spec=self.fields)
示例#2
0
 def test_main_exit_functionality_success_with_issue_attr_dict(self, mock_hostset, mock_module, mock_client):
     """
     hpe3par hostset - 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_hostset.return_value = (
         True, True, "Created hostset host successfully.", {"dummy": "dummy"})
     hostset.main()
     # AnsibleModule.exit_json should be called
     instance.exit_json.assert_called_with(
         changed=True, msg="Created hostset host successfully.", issue={"dummy": "dummy"})
     # AnsibleModule.fail_json should not be called
     self.assertEqual(instance.fail_json.call_count, 0)
示例#3
0
    def test_main_exit_functionality_fail(self, mock_hostset, mock_module, mock_client):
        """
        hpe3par hostset - 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_hostset.return_value = (
            False, False, "hostset creation failed.", {"dummy": "dummy"})
        hostset.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='hostset creation failed.')