Skip to content

Commit

Permalink
Address comments, adjust some assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
damoore044 committed Jan 11, 2024
1 parent 2fbf45a commit 6c4c990
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
6 changes: 3 additions & 3 deletions robottelo/host_helpers/api_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,10 +677,10 @@ def wait_for_errata_applicability_task(
for _ in range(max_tries):
now = int(time.time())
# Format epoch time for search, one second prior margin of safety
timestamp = datetime.fromtimestamp(from_when - 1).strftime("%m-%d-%Y %H:%M:%S")
timestamp = datetime.fromtimestamp(from_when - 1).strftime('%m-%d-%Y %H:%M:%S')
# Long format to match search: ex. 'January 03, 2024 at 03:08:08 PM'
long_format = datetime.strptime(timestamp, "%m-%d-%Y %H:%M:%S").strftime(
"%B %d, %Y at %I:%M:%S %p"
long_format = datetime.strptime(timestamp, '%m-%d-%Y %H:%M:%S').strftime(
'%B %d, %Y at %I:%M:%S %p'
)
search_query = (
'( label = Actions::Katello::Applicability::Hosts::BulkGenerate OR'
Expand Down
37 changes: 19 additions & 18 deletions tests/foreman/api/test_errata.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@
"""
# For ease of use hc refers to host-collection throughout this document
from time import sleep, time
from robottelo.logging import logger

# from datetime import datetime
import pytest

from robottelo import constants
from robottelo.config import settings
from robottelo.constants import (
DEFAULT_ARCHITECTURE,
DEFAULT_SUBSCRIPTION_NAME,
FAKE_1_CUSTOM_PACKAGE,
FAKE_2_CUSTOM_PACKAGE,
FAKE_2_CUSTOM_PACKAGE_NAME,
Expand Down Expand Up @@ -869,27 +867,31 @@ def test_positive_install_multiple_in_host(
len(updated_packages) > 0
), f'No applicable packages were found or installed from list: {FAKE_9_YUM_UPDATED_PACKAGES}.'
# Each expected erratum and packages installed only once
assert set(updated_packages), f'Expect no repeated packages in install list: {updated_packages}'
assert set(installed_errata), f'Expect no repeated errata in install list: {installed_errata}'
pkg_set = set(updated_packages)
errata_set = set(installed_errata)
assert len(pkg_set) == len(updated_packages), f'Expect no repeat packages in install list: {updated_packages}.'
assert len(errata_set) == len(installed_errata), f'Expected no repeat errata in install list: {installed_errata}.'
# Only the expected YUM_9 packages were installed
assert set(updated_packages).issubset(set(FAKE_9_YUM_UPDATED_PACKAGES))
# Only the expected YUM_9 errata were updated
assert set(installed_errata).issubset(set(FAKE_9_YUM_SECURITY_ERRATUM))
# Check number of installed errata and unique names matches expected
# Check number of installed errata id(s) matches expected
assert len(installed_errata) == len(expected_errata_to_install), (
f'Expected to install {len(expected_errata_to_install)} errata from list: {FAKE_9_YUM_SECURITY_ERRATUM},'
f' but installed: {len(installed_errata)}.'
)
# Check sets of installed errata id(s) strings, matches expected
assert set(installed_errata) == set(expected_errata_to_install), (
'Sets containing unique errata_ids did not match. Actual installs verse Expected installs.'
'Expected errata id(s) and installed errata id(s) are not the same.'
)
# Check number of updated packages and unique names match expected
# Check number of updated package version filename(s) matches expected
assert len(updated_packages) == len(security_packages_to_install), (
f'Expected to install {len(security_packages_to_install)} packages from list: {FAKE_9_YUM_UPDATED_PACKAGES},'
f' but installed {len(updated_packages)}.'
)
# Check sets of installed package filename(s) strings, matches expected
assert set(updated_packages) == set(security_packages_to_install), (
'Sets containing unique package_filenames did not match. Actual installs verse Expected installs.'
'Expected package version filename(s) and installed package version filenam(s) are not the same.'
)


Expand Down Expand Up @@ -954,7 +956,7 @@ def test_positive_list_sorted_filtered(custom_repo, target_sat):
erratum_list = target_sat.api.Errata(repository=custom_repo['repository-id']).search(
query={'order': 'cve DESC', 'per_page': '1000'}
)
# Most of Errata won't have any CVEs. Removing empty CVEs from results
# Most Errata won't have any CVEs. Removing empty CVEs from results
erratum_cves = [errata.cves for errata in erratum_list if errata.cves]
# Verifying each errata have its CVEs sorted in DESC order
for errata_cves in erratum_cves:
Expand All @@ -978,7 +980,7 @@ def setup_content_rhel8(
Raises `AssertionError` if one or more of the setup components read are empty.
:return: if return_result is True:
:return: if return_result is True: otherwise None
A dictionary (_result) with the satellite instances of activaton-key, organization,
content-view, lifecycle-environment, rh_repo, custom_repo.
"""
Expand Down Expand Up @@ -1017,8 +1019,7 @@ def setup_content_rhel8(
assert all(
entry for entry in _result.values()
), f'One or more necessary components are not present: {_result}'
if return_result:
return _result
return _result if return_result else None


@pytest.mark.tier2
Expand Down Expand Up @@ -1319,10 +1320,10 @@ def _set_prerequisites_for_swid_repos(vm):
_run_remote_command_on_content_host(
f'curl --insecure --remote-name {settings.repos.swid_tools_repo}', vm
)
_run_remote_command_on_content_host("mv *swid*.repo /etc/yum.repos.d", vm)
_run_remote_command_on_content_host('mv *swid*.repo /etc/yum.repos.d', vm)
_run_remote_command_on_content_host(r'subscription-manager repos --enable \*', vm)
_run_remote_command_on_content_host("yum install -y swid-tools", vm)
_run_remote_command_on_content_host("dnf install -y dnf-plugin-swidtags", vm)
_run_remote_command_on_content_host('yum install -y swid-tools', vm)
_run_remote_command_on_content_host('yum install -y dnf-plugin-swidtags', vm)


def _validate_swid_tags_installed(vm, module_name):
Expand Down Expand Up @@ -1467,12 +1468,12 @@ def rhel8_module_ak(
# Ensure tools repo is enabled in the activation key
rhel8_module_ak.content_override(
data={
'content_overrides': [{'content_label': constants.REPOS['rhst8']['id'], 'value': '1'}]
'content_overrides': [{'content_label': REPOS['rhst8']['id'], 'value': '1'}]
}
)
# Fetch available subscriptions
subs = module_target_sat.api.Subscription(organization=module_entitlement_manifest_org).search(
query={'search': f'{constants.DEFAULT_SUBSCRIPTION_NAME}'}
query={'search': f'{DEFAULT_SUBSCRIPTION_NAME}'}
)
assert subs
# Add default subscription to activation key
Expand Down

0 comments on commit 6c4c990

Please sign in to comment.