Skip to content

Commit

Permalink
Add pytest for CM Service module
Browse files Browse the repository at this point in the history
Signed-off-by: rsuplina <[email protected]>
  • Loading branch information
rsuplina committed Jan 11, 2024
1 parent 3fcbe08 commit dbe5ffe
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions tests/unit/plugins/modules/cm_service/test_cm_service.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# -*- coding: utf-8 -*-

# Copyright 2024 Cloudera, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import absolute_import, division, print_function

__metaclass__ = type
import os
import logging
import pytest

from ansible_collections.cloudera.cluster.plugins.modules import cm_service
from ansible_collections.cloudera.cluster.tests.unit import AnsibleExitJson, AnsibleFailJson

LOG = logging.getLogger(__name__)

def test_pytest_cm_service(module_args):
module_args(
{
"username": os.getenv('CM_USERNAME'),
"password": os.getenv('CM_PASSWORD'),
"host": os.getenv('CM_HOST'),
"port": "7180",
"verify_tls": "no",
"debug": "yes",
"state": "started",
"role" : [ "SERVICEMONITOR" , "HOSTMONITOR", "EVENTSERVER", "ALERTPUBLISHER" ]
}
)

# with pytest.raises(AnsibleFailJson, match=r"boom") as e:
with pytest.raises(AnsibleExitJson) as e:
cm_service.main()

# LOG.info(str(e.value))
LOG.info(str(e.value.cloudera_manager))

0 comments on commit dbe5ffe

Please sign in to comment.