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 24, 2024
1 parent f9269b5 commit 8d56e76
Showing 1 changed file with 44 additions and 2 deletions.
46 changes: 44 additions & 2 deletions tests/foreman/ui/test_ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
"""
"""

0 comments on commit 8d56e76

Please sign in to comment.