Skip to content

Commit

Permalink
fix cli errata tests and update cli factory method
Browse files Browse the repository at this point in the history
  • Loading branch information
vijaysawant committed Dec 19, 2023
1 parent e17e37b commit 1b6cc16
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 22 deletions.
14 changes: 5 additions & 9 deletions robottelo/host_helpers/cli_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,15 +717,6 @@ def _setup_org_for_a_rh_repo(self, options=None):
env_id = self.make_lifecycle_environment({'organization-id': org_id})['id']
else:
env_id = options['lifecycle-environment-id']
# Clone manifest and upload it
with clone() as manifest:
self._satellite.put(manifest.path, manifest.name)
try:
self._satellite.cli.Subscription.upload(
{'file': manifest.name, 'organization-id': org_id}
)
except CLIReturnCodeError as err:
raise CLIFactoryError(f'Failed to upload manifest\n{err.msg}')
# Enable repo from Repository Set
try:
self._satellite.cli.RepositorySet.enable(
Expand Down Expand Up @@ -820,6 +811,11 @@ def _setup_org_for_a_rh_repo(self, options=None):
),
}
)
# Override RHST product to true ( turned off by default in 6.14 )
rhel_repo = self._satellite.cli.Repository.info({'id': rhel_repo['id']})
self._satellite.cli.ActivationKey.content_override(
{'id': activationkey_id, 'content-label': rhel_repo['content-label'], 'value': 'true'}
)
return {
'activationkey-id': activationkey_id,
'content-view-id': cv_id,
Expand Down
25 changes: 12 additions & 13 deletions tests/foreman/cli/test_errata.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,14 @@ def products_with_repos(orgs, module_target_sat):


@pytest.fixture(scope='module')
def rh_repo(
module_entitlement_manifest_org, module_lce, module_cv, module_ak_cv_lce, module_target_sat
):
def rh_repo(module_sca_manifest_org, module_lce, module_cv, module_ak_cv_lce, module_target_sat):
"""Add a subscription for the Satellite Tools repo to activation key."""
module_target_sat.cli_factory.setup_org_for_a_rh_repo(
{
'product': PRDS['rhel'],
'repository-set': REPOSET['rhst7'],
'repository': REPOS['rhst7']['name'],
'organization-id': module_entitlement_manifest_org.id,
'organization-id': module_sca_manifest_org.id,
'content-view-id': module_cv.id,
'lifecycle-environment-id': module_lce.id,
'activationkey-id': module_ak_cv_lce.id,
Expand All @@ -153,13 +151,13 @@ def rh_repo(

@pytest.fixture(scope='module')
def custom_repo(
module_entitlement_manifest_org, module_lce, module_cv, module_ak_cv_lce, module_target_sat
module_sca_manifest_org, module_lce, module_cv, module_ak_cv_lce, module_target_sat
):
"""Create custom repo and add a subscription to activation key."""
module_target_sat.cli_factory.setup_org_for_a_custom_repo(
{
'url': REPO_WITH_ERRATA['url'],
'organization-id': module_entitlement_manifest_org.id,
'organization-id': module_sca_manifest_org.id,
'content-view-id': module_cv.id,
'lifecycle-environment-id': module_lce.id,
'activationkey-id': module_ak_cv_lce.id,
Expand Down Expand Up @@ -377,7 +375,7 @@ def filter_sort_errata(sat, org, sort_by_date='issued', filter_by_org=None):
# Build a sorted errata info list, which also contains the sort field.
errata_internal_ids = [errata['id'] for errata in errata_list]
sorted_errata_info = get_sorted_errata_info_by_id(
errata_internal_ids, sort_by=sort_by_date, sort_reversed=sort_reversed
sat, errata_internal_ids, sort_by=sort_by_date, sort_reversed=sort_reversed
)

sort_field_values = [errata[sort_by_date] for errata in sorted_errata_info]
Expand Down Expand Up @@ -933,7 +931,7 @@ def cleanup():
ids=('org_id', 'org_name', 'org_label', 'no_org_filter'),
)
def test_positive_list_filter_by_org_sort_by_date(
module_entitlement_manifest_org, rh_repo, custom_repo, filter_by_org, sort_by_date
module_sca_manifest_org, rh_repo, custom_repo, filter_by_org, sort_by_date, module_target_sat
):
"""Filter by organization and sort by date.
Expand All @@ -950,7 +948,8 @@ def test_positive_list_filter_by_org_sort_by_date(
:expectedresults: Errata are filtered by org and sorted by date.
"""
filter_sort_errata(
module_entitlement_manifest_org,
sat=module_target_sat,
org=module_sca_manifest_org,
sort_by_date=sort_by_date,
filter_by_org=filter_by_org,
)
Expand Down Expand Up @@ -1079,7 +1078,7 @@ def test_positive_list_filter_by_org(target_sat, products_with_repos, filter_by_

@pytest.mark.run_in_one_thread
@pytest.mark.tier3
def test_positive_list_filter_by_cve(module_entitlement_manifest_org, rh_repo, target_sat):
def test_positive_list_filter_by_cve(module_sca_manifest_org, rh_repo, target_sat):
"""Filter errata by CVE
:id: 7791137c-95a7-4518-a56b-766a5680c5fb
Expand All @@ -1094,7 +1093,7 @@ def test_positive_list_filter_by_cve(module_entitlement_manifest_org, rh_repo, t
target_sat.cli.RepositorySet.enable(
{
'name': REPOSET['rhva6'],
'organization-id': module_entitlement_manifest_org.id,
'organization-id': module_sca_manifest_org.id,
'product': PRDS['rhel'],
'releasever': '6Server',
'basearch': 'x86_64',
Expand All @@ -1103,14 +1102,14 @@ def test_positive_list_filter_by_cve(module_entitlement_manifest_org, rh_repo, t
target_sat.cli.Repository.synchronize(
{
'name': REPOS['rhva6']['name'],
'organization-id': module_entitlement_manifest_org.id,
'organization-id': module_sca_manifest_org.id,
'product': PRDS['rhel'],
}
)
repository_info = target_sat.cli.Repository.info(
{
'name': REPOS['rhva6']['name'],
'organization-id': module_entitlement_manifest_org.id,
'organization-id': module_sca_manifest_org.id,
'product': PRDS['rhel'],
}
)
Expand Down

0 comments on commit 1b6cc16

Please sign in to comment.