Skip to content

Commit

Permalink
Testing stream fixes for errata:cli
Browse files Browse the repository at this point in the history
  • Loading branch information
damoore044 committed Oct 12, 2023
1 parent 6d1786f commit 3a363d8
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions tests/foreman/cli/test_errata.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,22 +194,39 @@ def hosts(request):
@pytest.fixture(scope='module')
def register_hosts(
hosts,
module_entitlement_manifest_org,
module_ak_cv_lce,
module_org,
module_lce,
module_ak,
rh_repo,
custom_repo,
module_target_sat,
):
"""Register hosts to Satellite"""
for host in hosts:
host.install_katello_ca(module_target_sat)
host.register_contenthost(module_entitlement_manifest_org.name, module_ak_cv_lce.name)
host.enable_repo(REPOS['rhst7']['id'])
# host.install_katello_ca(module_target_sat)
# host.register_contenthost(module_entitlement_manifest_org.name, module_ak_cv_lce.name)
# host.enable_repo(REPOS['rhst7']['id'])
module_target_sat.cli_factory.setup_org_for_a_custom_repo(
{
'url': REPO_WITH_ERRATA['url'],
'organization-id': module_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,
loc=None,
)
assert host.subscribed

return hosts


@pytest.fixture
def errata_hosts(register_hosts):
def errata_hosts(register_hosts, module_target_sat, module_org, module_lce, module_ak):
"""Ensure that rpm is installed on host."""
for host in register_hosts:
# Remove all packages.
Expand All @@ -225,6 +242,7 @@ def errata_hosts(register_hosts):
result = host.execute(f'yum install -y {old_package}')
if result.status != 0:
pytest.fail(f'Failed to install {old_package}: {result.stdout} {result.stderr}')
host.execute('subscription-manager repos')
return register_hosts


Expand Down Expand Up @@ -667,7 +685,7 @@ def test_install_errata_to_one_host(
@pytest.mark.tier3
@pytest.mark.e2e
def test_positive_list_affected_chosts_by_erratum_restrict_flag(
request, module_entitlement_manifest_org, module_cv, module_lce, errata_hosts
target_sat, request, module_entitlement_manifest_org, module_cv, module_lce, errata_hosts
):
"""View a list of affected content hosts for an erratum filtered
with restrict flags. Applicability is calculated using the Library,
Expand Down Expand Up @@ -699,16 +717,14 @@ def test_positive_list_affected_chosts_by_erratum_restrict_flag(
:CaseAutomation: Automated
"""

# Uninstall package so that only the first errata applies.
for host in errata_hosts:
host.execute(f'yum erase -y {REPO_WITH_ERRATA["errata"][1]["package_name"]}')

host.execute('subscription-manager repos')
# 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,
Expand All @@ -729,6 +745,7 @@ def test_positive_list_affected_chosts_by_erratum_restrict_flag(
'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
Expand Down

0 comments on commit 3a363d8

Please sign in to comment.