Skip to content

Commit 391ed62

Browse files
authored
[6.19.z] Add test for Katello 11637 (#20862)
1 parent 5e8b554 commit 391ed62

1 file changed

Lines changed: 59 additions & 0 deletions

File tree

tests/foreman/ui/test_host.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4192,6 +4192,65 @@ def test_assign_multi_cv_from_host_page(
41924192
assert new_cv_env['content_view'] == module_cv_repo.name
41934193

41944194

4195+
@pytest.mark.rhel_ver_match(f'{settings.content_host.default_rhel_version}')
4196+
@pytest.mark.no_containers
4197+
def test_assign_different_cv_from_same_env(
4198+
module_target_sat,
4199+
module_org,
4200+
module_lce,
4201+
module_cv_repo,
4202+
rhel_contenthost,
4203+
):
4204+
"""Ensure that a host can be switched to a different content view in the same lifecycle environment
4205+
4206+
:id: 64ac7868-18a6-47cc-9a3d-e014bf3ac320
4207+
4208+
:steps:
4209+
1. Create a content view and an activation key associated with the content view and a new lifecycle environment.
4210+
2. Register a host using the activation key.
4211+
3. Create a second content view associated with the same lifecycle environment as the previous content view.
4212+
4. On the Overview tab of the details page for the host, select the 'Assign content view environments' action from the 'Content view environments' card dropdown.
4213+
5. Use the `Select content view` dropdown to select the content view created in step 3, then click the `Save` button.
4214+
4215+
:expectedresults:
4216+
The host's content view environment is updated to use the content view created in step 3.
4217+
4218+
:verifies: SAT-25846
4219+
"""
4220+
# Create activation key and register host
4221+
ak = module_target_sat.api.ActivationKey(
4222+
organization=module_org.id,
4223+
content_view=module_cv_repo.id,
4224+
environment=module_org.library.id,
4225+
).create()
4226+
result = rhel_contenthost.register(module_org, None, ak.name, module_target_sat)
4227+
assert result.status == 0
4228+
4229+
# Sync a new repo, add it to a new CV, and promote the CV
4230+
repo = module_target_sat.api.Repository(
4231+
product=module_target_sat.api.Product(organization=module_org).create(),
4232+
url=settings.repos.yum_0.url,
4233+
).create()
4234+
repo.sync()
4235+
cv = module_target_sat.api.ContentView(
4236+
organization=module_org.id, name=gen_string('alpha')
4237+
).create()
4238+
cv.repository = [repo]
4239+
cv.update(['repository'])
4240+
cv.publish()
4241+
cv_version = cv.read().version[0]
4242+
cv_version.promote(data={'environment_ids': module_lce.id})
4243+
cv = cv.read()
4244+
4245+
# In a UI session, use the CV environment modal to change the host's CV to the new CV
4246+
with module_target_sat.ui_session() as session:
4247+
session.organization.select(module_org.name)
4248+
session.host_new.switch_associated_cv(rhel_contenthost.hostname, cv.name)
4249+
4250+
cv_env = session.host_new.get_content_view_envs(rhel_contenthost.hostname)[0]
4251+
assert cv_env['content_view'] == cv.name
4252+
4253+
41954254
def test_positive_only_single_library_option_in_create_form(target_sat):
41964255
"""Ensure that only 1 Library option is displayed in the Create Host form
41974256
when location is set to "Any location"

0 commit comments

Comments
 (0)