Skip to content

Commit

Permalink
Fix AK tests assertion errors (#16220)
Browse files Browse the repository at this point in the history
* Fix AK tests assertion errors

* Use default_rhel_version and content_hosts fixture

* Remove obsoleted settings decorator
  • Loading branch information
vsedmik committed Sep 9, 2024
1 parent 539a72e commit 74d3b0f
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions tests/foreman/cli/test_activationkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@
from random import choice
import re

from broker import Broker
from fauxfactory import gen_alphanumeric, gen_string
import pytest

from robottelo.cli.defaults import Defaults
from robottelo.config import settings
from robottelo.constants import PRDS, REPOS, REPOSET
from robottelo.exceptions import CLIFactoryError, CLIReturnCodeError
from robottelo.hosts import ContentHost
from robottelo.utils.datafactory import (
invalid_values_list,
parametrized,
Expand Down Expand Up @@ -592,7 +590,8 @@ def test_negative_update_usage_limit(module_org, module_target_sat):

@pytest.mark.tier3
@pytest.mark.upgrade
def test_positive_usage_limit(module_org, module_location, target_sat):
@pytest.mark.rhel_ver_list([settings.content_host.default_rhel_version])
def test_positive_usage_limit(module_org, module_location, target_sat, content_hosts):
"""Test that Usage limit actually limits usage
:id: 00ded856-e939-4140-ac84-91b6a8643623
Expand All @@ -610,6 +609,7 @@ def test_positive_usage_limit(module_org, module_location, target_sat):
:CaseImportance: Critical
"""
max_hosts = 1
env = target_sat.cli_factory.make_lifecycle_environment({'organization-id': module_org.id})
new_cv = target_sat.cli_factory.make_content_view({'organization-id': module_org.id})
target_sat.cli.ContentView.publish({'id': new_cv['id']})
Expand All @@ -622,17 +622,16 @@ def test_positive_usage_limit(module_org, module_location, target_sat):
'lifecycle-environment-id': env['id'],
'content-view': new_cv['name'],
'organization-id': module_org.id,
'max-hosts': '1',
'max-hosts': max_hosts,
}
)
with Broker(nick='rhel7', host_class=ContentHost, _count=2) as clients:
vm1, vm2 = clients
vm1.register(module_org, module_location, new_ak['name'], target_sat)
assert vm1.subscribed
result = vm2.register(module_org, module_location, new_ak['name'], target_sat)
assert not vm2.subscribed
assert result.status == 70
assert len(result.stderr) > 0
vm1, vm2 = content_hosts
vm1.register(module_org, module_location, new_ak['name'], target_sat)
assert vm1.subscribed
result = vm2.register(module_org, module_location, new_ak['name'], target_sat)
assert not vm2.subscribed
assert result.status, 'Second registration was expected to fail'
assert f"Max Hosts ({max_hosts}) reached for activation key '{new_ak.name}'" in result.stderr


@pytest.mark.tier2
Expand Down Expand Up @@ -728,7 +727,7 @@ def test_positive_add_redhat_product(function_entitlement_manifest_org, target_s

@pytest.mark.tier3
@pytest.mark.skipif((not settings.robottelo.REPOS_HOSTING_URL), reason='Missing repos_hosting_url')
def test_positive_add_custom_product(module_org, module_target_sat):
def test_positive_add_custom_product(function_org, module_target_sat):
"""Test that custom product can be associated to Activation Keys
:id: 96ace967-e165-4069-8ff7-f54c4c822de0
Expand All @@ -739,11 +738,15 @@ def test_positive_add_custom_product(module_org, module_target_sat):
:BZ: 1426386
"""
result = module_target_sat.cli_factory.setup_org_for_a_custom_repo(
{'url': settings.repos.yum_0.url, 'organization-id': module_org.id}
{'url': settings.repos.yum_0.url, 'organization-id': function_org.id}
)
repo = module_target_sat.cli.Repository.info({'id': result['repository-id']})
content = module_target_sat.cli.ActivationKey.product_content(
{'id': result['activationkey-id'], 'organization-id': module_org.id}
{
'id': result['activationkey-id'],
'organization-id': function_org.id,
'content-access-mode-all': 1,
}
)
assert content[0]['name'] == repo['name']

Expand Down

0 comments on commit 74d3b0f

Please sign in to comment.