Skip to content

Commit

Permalink
Edit linting issues
Browse files Browse the repository at this point in the history
Signed-off-by: rsuplina <[email protected]>
  • Loading branch information
rsuplina committed Nov 22, 2024
1 parent 2c636ff commit fb93cff
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
7 changes: 4 additions & 3 deletions plugins/modules/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/user_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 23 additions & 10 deletions tests/unit/plugins/modules/user/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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))

0 comments on commit fb93cff

Please sign in to comment.