Skip to content

Commit

Permalink
fix tests from repositories component
Browse files Browse the repository at this point in the history
  • Loading branch information
vijaysawant committed Sep 13, 2024
1 parent 706ae54 commit 0d1b21d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
3 changes: 1 addition & 2 deletions tests/foreman/api/test_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,7 @@ def test_positive_filter_product_list(module_sca_manifest_org, module_target_sat
query={'redhat_only': True, 'per_page': 1000}
)

assert len(custom_products) == 1
assert product.name == custom_products[0].name
assert product.name in (custom_prod.name for custom_prod in custom_products)
assert 'Red Hat Beta' not in (prod.name for prod in custom_products)

assert len(rh_products) > 1
Expand Down
22 changes: 15 additions & 7 deletions tests/foreman/api/test_repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def test_positive_sync_upstream_repo_with_zst_compression(

@pytest.mark.tier1
@pytest.mark.manifester
def test_negative_upload_expired_manifest(module_org, target_sat):
def test_negative_upload_expired_manifest(request, default_org, target_sat):
"""Upload an expired manifest and attempt to refresh it
:id: d6e652d8-5f46-4d15-9191-d842466d45d0
Expand All @@ -240,10 +240,13 @@ def test_negative_upload_expired_manifest(module_org, target_sat):
"""
manifester = Manifester(manifest_category=settings.manifest.golden_ticket)
manifest = manifester.get_manifest()
target_sat.upload_manifest(module_org.id, manifest.content)
target_sat.upload_manifest(default_org.id, manifest.content)
request.addfinalizer(
lambda: target_sat.cli.Subscription.delete_manifest({'organization-id': default_org.id})
)
manifester.delete_subscription_allocation()
with pytest.raises(CLIReturnCodeError) as error:
target_sat.cli.Subscription.refresh_manifest({'organization-id': module_org.id})
target_sat.cli.Subscription.refresh_manifest({'organization-id': default_org.id})
assert (
"The manifest doesn't exist on console.redhat.com. "
"Please create and import a new manifest." in error.value.stderr
Expand Down Expand Up @@ -296,6 +299,7 @@ def test_positive_sync_mulitple_large_repos(module_target_sat, module_sca_manife
"""
repo_names = ['rhel8_bos', 'rhel8_aps']
kickstart_names = ['rhel8_bos', 'rhel8_aps']
all_repo_ids = []
for name in repo_names:
rh_repo_id = module_target_sat.api_factory.enable_rhrepo_and_fetchid(
basearch=DEFAULT_ARCHITECTURE,
Expand All @@ -305,6 +309,7 @@ def test_positive_sync_mulitple_large_repos(module_target_sat, module_sca_manife
reposet=REPOS[name]['reposet'],
releasever=REPOS[name]['releasever'],
)
all_repo_ids.append(rh_repo_id)

for name in kickstart_names:
rh_repo_id = module_target_sat.api_factory.enable_rhrepo_and_fetchid(
Expand All @@ -315,11 +320,14 @@ def test_positive_sync_mulitple_large_repos(module_target_sat, module_sca_manife
reposet=constants.REPOS['kickstart'][name]['reposet'],
releasever=constants.REPOS['kickstart'][name]['version'],
)
rh_repos = module_target_sat.api.Repository(id=rh_repo_id).read()
rh_products = module_target_sat.api.Product(id=rh_repos.product.id).read()
assert len(rh_products.repository) == 4
all_repo_ids.append(rh_repo_id)
rh_repo = module_target_sat.api.Repository(id=rh_repo_id).read()
rh_product = module_target_sat.api.Product(id=rh_repo.product.id).read()
assert len(rh_product.repository) >= 4
rh_product_repo_ids = [repo.id for repo in rh_product.repository]
assert set(all_repo_ids).issubset(rh_product_repo_ids)
res = module_target_sat.api.ProductBulkAction().sync(
data={'ids': [rh_products.id]}, timeout=2000
data={'ids': [rh_product.id]}, timeout=2000
)
assert res['result'] == 'success'

Expand Down

0 comments on commit 0d1b21d

Please sign in to comment.