Skip to content

Commit

Permalink
action on Hostgroup
Browse files Browse the repository at this point in the history
  • Loading branch information
amolpati30 committed Apr 15, 2024
1 parent 6e6af71 commit aa42e2e
Showing 1 changed file with 48 additions and 1 deletion.
49 changes: 48 additions & 1 deletion tests/foreman/ui/test_ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,53 @@ def test_positive_set_ansible_role_order_per_hostgroup(self):
:CaseAutomation: NotAutomated
"""

@pytest.mark.tier2
def test_positive_assign_and_remove_role_to_hostgroup(
self, target_sat, module_org, module_location
):
"""Add and remove functionality for ansible roles in hostgroup
:id: 5d94a484-92c1-4387-ab92-0649e4c4f907
:steps:
1. Import all roles available by default.
2. Create a hostgroup
3. Assign hostgroup to the host
4. Register a RHEL host to Satellite with given hostgroup.
5. Navigate to the new UI for the given hostgroup.
6. Add an ansible roles to the hostgroup
7. Remove the added ansible roles from the hostgroup
:expectedresults: The Ansible Role is successfully assign/add/remove from the hostgroup, and no longer shows
up on the UI
"""
SELECTED_ROLE = 'RedHatInsights.insights-client'
hostgroup = target_sat.api.HostGroup(
location=[module_location],
organization=[module_org],
).create()
host = target_sat.api.Host(
organization=module_org, location=module_location, hostgroup=hostgroup
).create()
location = host.location.read()
organization = host.organization.read()
with target_sat.ui_session() as session:
session.location.select(location.name)
session.organization.select(organization.name)
# assign ansible role to host-group
target_sat.api.AnsibleRoles().sync(
data={'proxy_id': target_sat.nailgun_smart_proxy.id, 'role_names': [SELECTED_ROLE]}
)
session.host_new.assign_role_to_hostgroup(host.name)
# verify ansible role assigned to new UI for given host-group
assert (
session.hostgroup.read(
host.hostgroup.read().name, widget_names='ansible_roles.assigned_role'
)['ansible_roles']['assigned_role'].split('. ')[1]
) == SELECTED_ROLE
# remove ansible role to host-group
session.host_new.remove_hostgroup_role(host.name)


class TestAnsibleREX:
"""Test class for remote execution via Ansible
Expand Down Expand Up @@ -635,4 +682,4 @@ def test_positive_schedule_recurring_hostgroup_job(self):
7. Navigate to Job Invocations.
:expectedresults: Scheduled Job appears in the Job Invocation list at the appointed time
"""
"""

0 comments on commit aa42e2e

Please sign in to comment.