From 49c801fa3701697e20b462d748ec18b798497e1c Mon Sep 17 00:00:00 2001 From: Pavel Novotny Date: Tue, 30 Apr 2024 16:43:43 +0200 Subject: [PATCH] host: inherit LCE & CV with nested hostgroup Bugzilla: https://bugzilla.redhat.com/2266432 Expanding test tests/foreman/api/test_host.py::test_positive_create_inherit_lce_cv to include also a nested hostgroup. --- tests/foreman/api/test_host.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/tests/foreman/api/test_host.py b/tests/foreman/api/test_host.py index e8982215ad7..22edb8648a8 100644 --- a/tests/foreman/api/test_host.py +++ b/tests/foreman/api/test_host.py @@ -246,26 +246,30 @@ def test_positive_create_inherit_lce_cv( module_default_org_view, module_lce_library, module_org, module_target_sat ): """Create a host with hostgroup specified. Make sure host inherited - hostgroup's lifecycle environment and content-view + hostgroup's lifecycle environment and content-view. + Make sure this also works with a nested hostgroup. :id: 229cbdbc-838b-456c-bc6f-4ac895badfbc :expectedresults: Host's lifecycle environment and content view match the ones specified in hostgroup - :BZ: 1391656 + :BZ: 1391656, 2266432 """ - hostgroup = module_target_sat.api.HostGroup( + parent_hg = module_target_sat.api.HostGroup( content_view=module_default_org_view, lifecycle_environment=module_lce_library, organization=[module_org], ).create() - host = module_target_sat.api.Host(hostgroup=hostgroup, organization=module_org).create() - assert ( - host.content_facet_attributes['lifecycle_environment']['id'] - == hostgroup.lifecycle_environment.id - ) - assert host.content_facet_attributes['content_view']['id'] == hostgroup.content_view.id + nested_hg = module_target_sat.api.HostGroup(parent=parent_hg).create() + + for hg in [parent_hg, nested_hg]: + host = module_target_sat.api.Host(hostgroup=hg, organization=module_org).create() + assert ( + host.content_facet_attributes['lifecycle_environment']['id'] + == hg.lifecycle_environment.id + ) + assert host.content_facet_attributes['content_view']['id'] == hg.content_view.id @pytest.mark.tier2