Skip to content

Commit

Permalink
ErrataManagement UI: Update show_count, and errata_tab_pagination cas…
Browse files Browse the repository at this point in the history
…es (#14520)

fix UI:Errata test_positive_list (#14514)

(cherry picked from commit a5fa458)
  • Loading branch information
damoore044 committed Apr 2, 2024
1 parent de293f1 commit a22fe46
Showing 1 changed file with 74 additions and 27 deletions.
101 changes: 74 additions & 27 deletions tests/foreman/ui/test_errata.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def registered_contenthost(
:note: rhel_contenthost will be parameterized by rhel6 to 9, also -fips for all distros.
to use specific rhel version parameterized contenthost;
use pytest.mark.rhel_ver_match() to mark contenthost version(s) for tests using this fixture.
use `pytest.mark.rhel_ver_match()` to mark contenthost version(s) for tests using this fixture.
:repos: pass as a parameterized request
list of upstream URLs for custom repositories.
Expand Down Expand Up @@ -654,10 +654,7 @@ def test_host_content_errata_tab_pagination(
pf4_pagination = session.host_new.get_errata_pagination(_chost_name)
assert (_read_page := pf4_pagination.read())
assert _read_page != _prior_pagination
# assert per_page and total_pages remained the same
assert pf4_pagination.current_per_page == 5
assert pf4_pagination.current_page == 1
assert pf4_pagination.total_pages > 1
# total_items decreased by one
item_count = pf4_pagination.total_items
assert item_count == _prior_app_count - 1
Expand Down Expand Up @@ -1194,59 +1191,109 @@ def test_positive_content_host_search_type(session, erratatype_vm):


@pytest.mark.tier3
@pytest.mark.rhel_ver_match('8')
@pytest.mark.parametrize(
'module_repos_collection_with_setup',
[
{
'distro': 'rhel7',
'SatelliteToolsRepository': {},
'RHELAnsibleEngineRepository': {'cdn': True},
'YumRepository': {'url': settings.repos.yum_9.url},
}
],
'registered_contenthost',
[[CUSTOM_REPO_URL]],
indirect=True,
)
def test_positive_show_count_on_content_host_page(
session, module_org_with_parameter, erratatype_vm
):
"""Available errata count displayed in Content hosts page
def test_positive_show_count_on_host_pages(session, module_org, registered_contenthost):
"""Available errata by type displayed in New Host>Errata page,
and expected count by type in Legacy>Content hosts page.
:id: 8575e282-d56e-41dc-80dd-f5f6224417cb
:Setup:
1. Errata synced on satellite server.
2. Some content hosts are present.
1. Errata synced on satellite server from custom repository.
2. Registered host, subscribed to promoted CVV, with repo synced to appliable custom packages and erratum.
:steps: Go to Hosts -> Content Hosts.
:steps:
:expectedresults: The available errata count is displayed.
1. Go to Hosts -> All Hosts, and Legacy ContentHost -> Hosts.
2. None of the erratum are installable.
3. Install all outdated applicable packages via yum.
4. Recalculate errata applicablity for host.
5. All of the erratum are now installable, on both pages from step 1.
:expectedresults:
The available errata count is displayed and updates.
Displayed erratum match between the two content host pages.
:BZ: 1484044, 1775427
:customerscenario: true
"""
vm = erratatype_vm
vm = registered_contenthost
hostname = vm.hostname
assert vm.subscribed
assert vm.execute('subscription-manager repos').status == 0
assert vm.applicable_errata_count == 0

with session:
session.location.select(loc_name=DEFAULT_LOC)
# new host UI
new_host_values = session.host_new.search(hostname)
assert new_host_values[0]['Name'] == hostname
# None of the erratum are installable
for errata_type in ('Security', 'Bugfix', 'Enhancement'):
installable_errata = None
empty_table = False
try:
# exception will be raised in case of unfound element (dropdown or dropdown entry)
# if an exception was raised, the table is missing/empty (no errata).
installable_errata = session.host_new.get_errata_by_type(
entity_name=hostname,
type=errata_type,
)['content']['errata']['table']
except Exception:
empty_table = True
assert (
not installable_errata
), f'Found some installable {errata_type} errata, when none were expected.'
assert empty_table
# legacy contenthost UI
content_host_values = session.contenthost.search(hostname)
assert content_host_values[0]['Name'] == hostname
installable_errata = content_host_values[0]['Installable Updates']['errata']

for errata_type in ('security', 'bug_fix', 'enhancement'):
assert int(installable_errata[errata_type]) == 0
assert (
int(installable_errata[errata_type]) == 0
), f'Found some installable {errata_type} errata, when none were expected.'

# install outdated packages, recalculate errata applicability
pkgs = ' '.join(FAKE_9_YUM_OUTDATED_PACKAGES)
assert vm.execute(f'yum install -y {pkgs}').status == 0

assert vm.execute('subscription-manager repos').status == 0
assert vm.applicable_errata_count == 5

# new host UI (errata tab)
new_host_values = session.host_new.search(hostname)
assert new_host_values[0]['Name'] == hostname
# erratum are installable
security_errata = session.host_new.get_errata_by_type(
entity_name=hostname,
type='Security',
)['content']['errata']['table']
assert len(security_errata) == FAKE_9_YUM_SECURITY_ERRATUM_COUNT
for errata_type in ('Bugfix', 'Enhancement'):
installable_errata = session.host_new.get_errata_by_type(
entity_name=hostname,
type=errata_type,
)['content']['errata']['table']
assert (
len(installable_errata) == 1
), f'Expected only one {errata_type} errata to be installable.'
# legacy contenthost UI
content_host_values = session.contenthost.search(hostname)
assert content_host_values[0]['Name'] == hostname
installable_errata = content_host_values[0]['Installable Updates']['errata']

# erratum are installable
assert int(installable_errata['security']) == FAKE_9_YUM_SECURITY_ERRATUM_COUNT
for errata_type in ('bug_fix', 'enhancement'):
assert int(installable_errata[errata_type]) == 1
assert (
int(installable_errata[errata_type]) == 1
), f'Expected only one {errata_type} errata to be installable.'


@pytest.mark.tier3
Expand Down

0 comments on commit a22fe46

Please sign in to comment.