Skip to content

Commit

Permalink
add & remove ansible role
Browse files Browse the repository at this point in the history
  • Loading branch information
amolpati30 committed Mar 28, 2024
1 parent ac4b0cf commit f3945c8
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions tests/foreman/ui/test_ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,28 +298,8 @@ def test_positive_role_variable_information(self):
"""


@pytest.mark.stubbed
@pytest.mark.tier2
def test_positive_assign_role_in_new_ui(self):
"""Using the new Host UI, assign a role to a Host
:id: 044f38b4-cff2-4ddc-b93c-7e9f2826d00d
:steps:
1. Register a RHEL host to Satellite.
2. Import all roles available by default.
3. Navigate to the new UI for the given Host.
4. Select the 'Ansible' tab
5. Click the 'Assign Ansible Roles' button.
6. Using the popup, assign a role to the Host.
:expectedresults: The Role is successfully assigned to the Host, and shows up on the UI
"""


@pytest.mark.stubbed
@pytest.mark.tier2
def test_positive_remove_role_in_new_ui(self):
def test_positive_add_and_remove_ansible_role_in_new_ui(target_sat, function_host):
"""Using the new Host UI, remove the role(s) of a Host
:id: d6de5130-45f6-4349-b490-fbde2aed082c
Expand All @@ -336,3 +316,27 @@ def test_positive_remove_role_in_new_ui(self):
:expectedresults: The Role is successfully removed from the Host, and no longer shows
up on the UI
"""
SELECTED_ROLE = 'RedHatInsights.insights-client'

location = function_host.location.read()
organization = function_host.organization.read()
proxy_id = target_sat.nailgun_smart_proxy.id
target_sat.api.AnsibleRoles().sync(data={'proxy_id': proxy_id, 'role_names': [SELECTED_ROLE]})
role_id = target_sat.api.AnsibleRoles().search(query={'search': f'name={SELECTED_ROLE}'})[0].id
target_sat.api.Host(id=function_host.id).add_ansible_role(data={'ansible_role_id': role_id})
host_roles = function_host.list_ansible_roles()
assert host_roles[0]['name'] == SELECTED_ROLE
with target_sat.ui_session() as session:
session.location.select(location.name)
session.organization.select(organization.name)
# verify ansible role assign to new UI for the given Host
ansible_roles_table = session.host_new.get_ansible_roles(function_host.name.split('.')[0])
assert ansible_roles_table[0]['Name'] == SELECTED_ROLE
session.host_new.remove_ansible_roles(function_host.name.split('.')[0])
# verify ansible role removed
result = session.host_new.get_details(
function_host.name.split('.')[0], widget_names='ansible.roles.noRoleAssign'
)
assert (
result['ansible']['roles']['noRoleAssign'] == 'No roles assigned directly to the host'
)

0 comments on commit f3945c8

Please sign in to comment.