From 8d56e7655ef8ead1f093a5ca05cfb69d92ad3bbc Mon Sep 17 00:00:00 2001 From: amolpati30 Date: Thu, 4 Apr 2024 21:07:55 +0530 Subject: [PATCH] action on Hostgroup --- tests/foreman/ui/test_ansible.py | 46 ++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/tests/foreman/ui/test_ansible.py b/tests/foreman/ui/test_ansible.py index f3d308ed230..90dffde7dcb 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,48 @@ 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. Navigate to the hostgroup page. + 5. Add all ansible roles to the hostgroup + 6. Remove all 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 + """ + 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() + hstgrp_name = host.hostgroup.read().name + with target_sat.ui_session() as session: + synced_all_role = session.ansibleroles.import_all_roles() + total_imported_roles = session.ansibleroles.imported_roles_count + # verify all roles are synced + assert synced_all_role == total_imported_roles + session.location.select(module_location.name) + session.organization.select(module_org.name) + # assign all ansible roles to host-group + session.host_new.assign_all_role_to_hostgroup(host.name) + # verify all ansible roles are assigned to given host-group + assert session.hostgroup.total_no_of_assigned_role(hstgrp_name) == total_imported_roles + # remove ansible role from host-group + session.host_new.remove_all_role_from_hostgroup(host.name) + # verify all ansible roles are removed from host-group + assert session.host_new.remove_all_role_from_hostgroup(host.name) is None + class TestAnsibleREX: """Test class for remote execution via Ansible @@ -683,4 +725,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 + """