From fb93cff2c6dfcc5cc67c716271eeeff2f432628e Mon Sep 17 00:00:00 2001 From: rsuplina Date: Fri, 22 Nov 2024 10:25:40 +0000 Subject: [PATCH] Edit linting issues Signed-off-by: rsuplina --- plugins/modules/user.py | 7 +++-- plugins/modules/user_info.py | 2 +- tests/unit/plugins/modules/user/test_user.py | 33 ++++++++++++++------ 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/plugins/modules/user.py b/plugins/modules/user.py index 7845631b..95cfcc39 100644 --- a/plugins/modules/user.py +++ b/plugins/modules/user.py @@ -93,7 +93,7 @@ state: "Present" purge: false -- name: Add additional roles to user +- name: Add additional roles to user cloudera.cluster.user: host: example.cloudera.com port: "7180" @@ -203,7 +203,6 @@ def process(self): else: roles_to_add = list(set(existing_roles) | set(incoming_roles)) - if roles_to_add: auth_roles = [ ApiAuthRoleRef(uuid=role_uuid) for role_uuid in roles_to_add @@ -255,7 +254,9 @@ def process(self): if self.state == "absent": if existing: - self.user_output = api_instance.delete_user2(self.account_name).to_dict() + self.user_output = api_instance.delete_user2( + self.account_name + ).to_dict() self.changed = True diff --git a/plugins/modules/user_info.py b/plugins/modules/user_info.py index f71dc4f5..f740e51a 100644 --- a/plugins/modules/user_info.py +++ b/plugins/modules/user_info.py @@ -65,7 +65,7 @@ RETURN = r""" --- user_info: - description: + description: - Retrieve details of single user or all users within the Cloudera Manager type: list elements: dict diff --git a/tests/unit/plugins/modules/user/test_user.py b/tests/unit/plugins/modules/user/test_user.py index 1b1c3608..f34e039c 100644 --- a/tests/unit/plugins/modules/user/test_user.py +++ b/tests/unit/plugins/modules/user/test_user.py @@ -49,14 +49,14 @@ def conn(): "debug": "no", } + def test_pytest_create_new_user(module_args, conn): conn.update( - account_name = 'John', - account_password = 'passowrd', - roles=['Configurator','Dashboard User','Limited Operator'], - state = "present", - purge = True, - + account_name="John", + account_password="passowrd", + roles=["Configurator", "Dashboard User", "Limited Operator"], + state="present", + purge=True, ) module_args(conn) @@ -66,11 +66,12 @@ def test_pytest_create_new_user(module_args, conn): LOG.info(str(e.value.user_output)) -def test_pytest_remove_user(module_args, conn): - conn.update( - account_name = 'John', - state = "absent", +def test_pytest_create_new_admin_user(module_args, conn): + conn.update( + account_name="Admin2", + account_password="passowrd", + roles=["Full Administrator"], ) module_args(conn) @@ -81,3 +82,15 @@ def test_pytest_remove_user(module_args, conn): LOG.info(str(e.value.user_output)) +def test_pytest_remove_user(module_args, conn): + conn.update( + account_name="John", + state="absent", + ) + + module_args(conn) + + with pytest.raises(AnsibleExitJson) as e: + user.main() + + LOG.info(str(e.value.user_output))