diff --git a/tests/foreman/ui/test_ansible.py b/tests/foreman/ui/test_ansible.py index f3d308ed230..6f48be5057c 100644 --- a/tests/foreman/ui/test_ansible.py +++ b/tests/foreman/ui/test_ansible.py @@ -10,11 +10,11 @@ """ from fauxfactory import gen_string import pytest -from wait_for import wait_for import yaml from robottelo import constants from robottelo.config import robottelo_tmp_dir, settings +from wait_for import wait_for class TestAnsibleCfgMgmt: @@ -448,6 +448,52 @@ def test_positive_assign_and_remove_ansible_role_to_host(self, target_sat, funct == 'No roles assigned directly to the host' ) + 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) + target_sat.api.AnsibleRoles().sync( + data={'proxy_id': target_sat.nailgun_smart_proxy.id, 'role_names': [SELECTED_ROLE]} + ) + # assign ansible role to host-group + 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 @@ -683,4 +729,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 - """ \ No newline at end of file + """