Skip to content

Commit

Permalink
AK UI test fix (#17631)
Browse files Browse the repository at this point in the history
* AK UI test fix

* Remove leftover code

* Change assert
  • Loading branch information
LadislavVasina1 authored Feb 20, 2025
1 parent 81400b9 commit 5528067
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions tests/foreman/ui/test_activationkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,10 @@ def test_positive_delete_with_system(session, rhel_contenthost, target_sat):


@pytest.mark.tier3
def test_negative_usage_limit(session, module_org, target_sat, module_promoted_cv, module_lce):
@pytest.mark.rhel_ver_match('N-2')
def test_negative_usage_limit(
session, module_org, target_sat, module_promoted_cv, module_lce, mod_content_hosts
):
"""Test that Usage limit actually limits usage
:id: 9fe2d661-66f8-46a4-ae3f-0a9329494bdd
Expand All @@ -940,23 +943,25 @@ def test_negative_usage_limit(session, module_org, target_sat, module_promoted_c
"""
name = gen_string('alpha')
hosts_limit = '1'
with session:
with target_sat.ui_session() as session:
session.location.select(constants.DEFAULT_LOC)
session.organization.select(module_org.name)
session.activationkey.create(
{'name': name, 'lce': {module_lce.name: True}, 'content_view': module_promoted_cv.name}
)
assert session.activationkey.search(name)[0]['Name'] == name
session.activationkey.update(name, {'details.hosts_limit': hosts_limit})
session.activationkey.update_ak_host_limit(name, int(hosts_limit))
ak = session.activationkey.read(name, widget_names='details')
assert ak['details']['hosts_limit'] == hosts_limit
with Broker(nick='rhel6', host_class=ContentHost, _count=2) as hosts:
vm1, vm2 = hosts
result = vm1.register(module_org, None, name, target_sat)
assert result.status == 0, f'Failed to register host: {result.stderr}'
assert vm1.subscribed
result = vm2.register(module_org, None, name, target_sat)
assert not vm2.subscribed
assert len(result.stderr)
assert f'Max Hosts ({hosts_limit}) reached for activation key' in str(result.stderr)

vm1, vm2 = mod_content_hosts
result = vm1.register(module_org, None, name, target_sat)
assert result.status == 0, f'Failed to register host: {result.stderr}'
assert vm1.subscribed
result = vm2.register(module_org, None, name, target_sat)
assert not vm2.subscribed
assert result.status
assert f'Max Hosts ({hosts_limit}) reached for activation key' in str(result.stderr)


@pytest.mark.no_containers
Expand Down

0 comments on commit 5528067

Please sign in to comment.