From 3f6b2eeca3f22ae6fcd1a24149d5b24799757b7f Mon Sep 17 00:00:00 2001 From: David Moore Date: Fri, 13 Oct 2023 18:21:23 -0400 Subject: [PATCH] Initial pass, prt candidate --- tests/foreman/cli/test_errata.py | 44 ++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/tests/foreman/cli/test_errata.py b/tests/foreman/cli/test_errata.py index e37636b646b..73f8216746e 100644 --- a/tests/foreman/cli/test_errata.py +++ b/tests/foreman/cli/test_errata.py @@ -26,7 +26,7 @@ from robottelo.cli.activationkey import ActivationKey from robottelo.cli.base import CLIReturnCodeError -from robottelo.cli.contentview import ContentView, ContentViewFilter +from robottelo.cli.contentview import ContentViewFilter from robottelo.cli.erratum import Erratum from robottelo.cli.factory import ( make_content_view_filter, @@ -361,25 +361,28 @@ def filter_sort_errata(org, sort_by_date='issued', filter_by_org=None): assert errata_ids == sorted_errata_ids -def cv_publish_promote(cv, org, lce): +def cv_publish_promote(sat, cv, lce): """Publish and promote a new version into the given lifecycle environment. :param cv: content view :type cv: entities.ContentView - :param org: organization - :type org: entities.Organization + #:param org: organization + #:type org: entities.Organization :param lce: lifecycle environment :type lce: entities.LifecycleEnvironment """ - ContentView.publish({'id': cv.id}) - cvv = ContentView.info({'id': cv.id})['versions'][-1] - ContentView.version_promote( + cv.publish() + cv = cv.read() + cvv = cv.version[-1].read() + cvv.promote(data={'environment_ids': lce.id, 'force': True}) + """ContentView.version_promote( { 'id': cvv['id'], 'organization-id': org.id, 'to-lifecycle-environment-id': lce.id, + 'activation-key-id': ak.id } - ) + )""" def cv_filter_cleanup(filter_id, cv, org, lce): @@ -689,7 +692,13 @@ def test_install_errata_to_one_host( @pytest.mark.tier3 @pytest.mark.e2e def test_positive_list_affected_chosts_by_erratum_restrict_flag( - target_sat, request, module_entitlement_manifest_org, module_cv, module_lce, errata_hosts + target_sat, + request, + module_entitlement_manifest_org, + module_cv, + module_lce, + errata_hosts, + module_ak, ): """View a list of affected content hosts for an erratum filtered with restrict flags. Applicability is calculated using the Library, @@ -721,13 +730,20 @@ def test_positive_list_affected_chosts_by_erratum_restrict_flag( :CaseAutomation: Automated """ + applicable_errata_num = {} # Uninstall package so that only the first errata applies. for host in errata_hosts: host.execute(r'subscription-manager repos --enable \*') host.execute(r'yum-config-manager --enable \*') host.execute(f'yum erase -y {REPO_WITH_ERRATA["errata"][1]["package_name"]}') host.execute('subscription-manager repos') - sleep(20) + sleep(20) + target_sat.cli.Host.errata_recalculate({'host-id': host.nailgun_host.id}) + applicable_errata_num[host.hostname] = host.applicable_errata_count + + for host in errata_hosts: + print(applicable_errata_num[host.hostname]) + # Create list of uninstallable errata. errata = REPO_WITH_ERRATA['errata'][0] uninstallable = REPO_WITH_ERRATA['errata_ids'].copy() @@ -740,20 +756,20 @@ def test_positive_list_affected_chosts_by_erratum_restrict_flag( 'per-page': PER_PAGE_LARGE, } errata_ids = get_errata_ids(param) + assert errata_ids, 'No installable errata found' assert errata['id'] in errata_ids, 'Errata not found in list of installable errata' assert not set(uninstallable) & set(errata_ids), 'Unexpected errata found' # Check search of errata is not affected by installable=0 restrict flag param = { 'errata-restrict-installable': 0, - 'content-view-id': module_cv.id, 'lifecycle-environment-id': module_lce.id, 'organization-id': module_entitlement_manifest_org.id, 'per-page': PER_PAGE_LARGE, } errata_ids = get_errata_ids(param) assert set(REPO_WITH_ERRATA['errata_ids']).issubset( - errata_ids + set(errata_ids) ), 'Errata not found in list of installable errata' # Check list of applicable errata @@ -773,7 +789,7 @@ def test_positive_list_affected_chosts_by_erratum_restrict_flag( } errata_ids = get_errata_ids(param) assert set(REPO_WITH_ERRATA['errata_ids']).issubset( - errata_ids + set(errata_ids) ), 'Errata not found in list of applicable errata' # Apply a filter and rule to the CV to hide the RPM, thus making erratum not installable @@ -808,7 +824,7 @@ def cleanup(): ) # Publish and promote a new version with the filter - cv_publish_promote(module_cv, module_entitlement_manifest_org, module_lce) + cv_publish_promote(sat=target_sat, cv=module_cv, lce=module_lce) # Check that the installable erratum is no longer present in the list param = {