Skip to content

Commit e7561d0

Browse files
LadislavVasina1web-flow
authored andcommitted
SAT-44548 coverage (#22195)
SAT-44548-coverage (cherry picked from commit de607c0)
1 parent 3b44038 commit e7561d0

1 file changed

Lines changed: 76 additions & 0 deletions

File tree

tests/foreman/ui/test_host.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3426,6 +3426,82 @@ def cleanup():
34263426
)
34273427

34283428

3429+
def test_positive_bulk_change_location_select_all_respects_context(
3430+
module_target_sat,
3431+
request,
3432+
):
3433+
"""Verify bulk 'Change Location' via 'Select All' only affects hosts
3434+
in the current location context, not all hosts across the Satellite.
3435+
3436+
:id: 235fa529-0a35-41a3-98f2-73d2ba3de5ef
3437+
3438+
:Verifies: SAT-44548
3439+
3440+
:steps:
3441+
1. Create an organization with three locations (X, Y, Z)
3442+
2. Create three fake hosts in location X and two in location Y
3443+
3. Navigate to All Hosts page with location X selected
3444+
4. Select all hosts using the 'Select All' checkbox
3445+
5. Use bulk action to change location to Z
3446+
6. Verify hosts originally in location X are now in location Z
3447+
7. Verify hosts in location Y remain unaffected
3448+
3449+
:expectedresults:
3450+
1. Bulk 'Change Location' with 'Select All' respects the current
3451+
location context and only moves hosts from that location
3452+
2. Hosts in other locations are not affected by the bulk action
3453+
"""
3454+
org = module_target_sat.api.Organization().create()
3455+
loc_x, loc_y, loc_z = [
3456+
module_target_sat.api.Location(organization=[org]).create() for _ in range(3)
3457+
]
3458+
3459+
hosts_x_names = []
3460+
for _ in range(3):
3461+
host = module_target_sat.cli_factory.make_fake_host(
3462+
{'organization': org.name, 'location': loc_x.name}
3463+
)
3464+
hosts_x_names.append(host['name'])
3465+
3466+
hosts_y_names = []
3467+
for _ in range(2):
3468+
host = module_target_sat.cli_factory.make_fake_host(
3469+
{'organization': org.name, 'location': loc_y.name}
3470+
)
3471+
hosts_y_names.append(host['name'])
3472+
3473+
@request.addfinalizer
3474+
def cleanup():
3475+
for host_name in hosts_x_names + hosts_y_names:
3476+
hosts = module_target_sat.api.Host().search(query={'search': f'name={host_name}'})
3477+
if hosts:
3478+
hosts[0].delete()
3479+
for loc in [loc_x, loc_y, loc_z]:
3480+
loc.delete()
3481+
org.delete()
3482+
3483+
with module_target_sat.ui_session() as session:
3484+
session.organization.select(org.name)
3485+
session.location.select(loc_x.name)
3486+
3487+
session.all_hosts.change_associations_location(
3488+
select_all_hosts=True,
3489+
new_location=loc_z.name,
3490+
)
3491+
3492+
for host_name in hosts_x_names:
3493+
host_entity = module_target_sat.api.Host().search(query={'search': f'name={host_name}'})[0]
3494+
assert host_entity.location.id == loc_z.id, (
3495+
f'Host {host_name} was not moved from location X to Z!'
3496+
)
3497+
3498+
for host_name in hosts_y_names:
3499+
host_entity = module_target_sat.api.Host().search(query={'search': f'name={host_name}'})[0]
3500+
assert host_entity.location.id == loc_y.id, (
3501+
f'Host {host_name} in location Y was incorrectly affected by bulk action!'
3502+
)
3503+
3504+
34293505
def read_host_collections_hosts(target_sat, host_col_names, org):
34303506
"""
34313507
Helper function to read hosts in a host collections via API.

0 commit comments

Comments
 (0)