Skip to content

Commit

Permalink
testing for prt
Browse files Browse the repository at this point in the history
  • Loading branch information
damoore044 committed Oct 13, 2023
1 parent 3a363d8 commit 1c8d66a
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions tests/foreman/cli/test_errata.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"""
from datetime import date, datetime, timedelta
from operator import itemgetter
from time import sleep

from broker import Broker
from nailgun import entities
Expand Down Expand Up @@ -194,9 +195,10 @@ def hosts(request):
@pytest.fixture(scope='module')
def register_hosts(
hosts,
module_org,
module_entitlement_manifest_org,
module_lce,
module_ak,
module_cv,
rh_repo,
custom_repo,
module_target_sat,
Expand All @@ -209,15 +211,15 @@ def register_hosts(
module_target_sat.cli_factory.setup_org_for_a_custom_repo(
{
'url': REPO_WITH_ERRATA['url'],
'organization-id': module_org.id,
'organization-id': module_entitlement_manifest_org.id,
'lifecycle-environment-id': module_lce.id,
'activationkey-id': module_ak.id,
}
)
host.register(
activation_keys=module_ak.name,
target=module_target_sat,
org=module_org,
org=module_entitlement_manifest_org,
loc=None,
)
assert host.subscribed
Expand All @@ -230,6 +232,8 @@ def errata_hosts(register_hosts, module_target_sat, module_org, module_lce, modu
"""Ensure that rpm is installed on host."""
for host in register_hosts:
# Remove all packages.
host.execute(r'subscription-manager repos --enable \*')
host.execute(r'yum-config-manager --enable \*')
for errata in REPO_WITH_ERRATA['errata']:
# Remove package if present, old or new.
package_name = errata['package_name']
Expand Down Expand Up @@ -300,8 +304,9 @@ def get_sorted_errata_info_by_id(errata_ids, sort_by='issued', sort_reversed=Fal
return sorted(errata_info, key=itemgetter(sort_by), reverse=sort_reversed)


def get_errata_ids(*params):
def get_errata_ids(self, *params):
"""Return list of sets of errata ids corresponding to the provided params."""
# self.run('subscription-manager repos')
errata_ids = [{errata['errata-id'] for errata in Erratum.list(param)} for param in params]
return errata_ids[0] if len(errata_ids) == 1 else errata_ids

Expand Down Expand Up @@ -719,16 +724,18 @@ def test_positive_list_affected_chosts_by_erratum_restrict_flag(
"""
# 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)
# Create list of uninstallable errata.
errata = REPO_WITH_ERRATA['errata'][0]
uninstallable = REPO_WITH_ERRATA['errata_ids'].copy()
uninstallable.remove(errata['id'])
# Check search for only installable errata
param = {
'errata-restrict-installable': 1,
'content-view-id': module_cv.id,
'lifecycle-environment-id': module_lce.id,
'organization-id': module_entitlement_manifest_org.id,
'per-page': PER_PAGE_LARGE,
Expand Down

0 comments on commit 1c8d66a

Please sign in to comment.