diff --git a/tests/foreman/ui/test_ansible.py b/tests/foreman/ui/test_ansible.py index abf6217e515..9e185d8f363 100644 --- a/tests/foreman/ui/test_ansible.py +++ b/tests/foreman/ui/test_ansible.py @@ -413,21 +413,49 @@ def test_positive_remove_role_in_new_ui(self): """ -@pytest.mark.stubbed +# @pytest.mark.stubbed @pytest.mark.tier2 -def test_positive_assign_and_remove_role_to_hostgroup_in_new_ui(self): - """Using the new Host UI, add and remove functionality for ansible roles in hostgroup +def test_positive_assign_and_remove_role_to_hostgroup( + module_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. Add some ansible roles to the 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. Remove the added ansible roles from the 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 - """ \ No newline at end of file + """ + SELECTED_ROLE = 'RedHatInsights.insights-client' + + hostgroup = module_target_sat.api.HostGroup( + location=[module_location], organization=[module_org] + ).create() + host = module_target_sat.api.Host( + organization=module_org, location=module_location, hostgroup=hostgroup + ).create() + location = host.location.read() + organization = host.organization.read() + with module_target_sat.ui_session() as session: + session.location.select(location.name) + session.organization.select(organization.name) + # 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_role = session.host_new.remove_hostgroup_role(host.name) + # verify ansible role removed in host-group + assert remove_role != SELECTED_ROLE