Skip to content

Commit

Permalink
[6.14.z] Fix discovery rule tests (#13483)
Browse files Browse the repository at this point in the history
Fix discovery rule tests (#13426)

Signed-off-by: Shubham Ganar <[email protected]>
(cherry picked from commit f415a64)

Co-authored-by: Shubham Ganar <[email protected]>
  • Loading branch information
Satellite-QE and shubhamsg199 authored Dec 19, 2023
1 parent 1bcfcdf commit 4cece4a
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions tests/foreman/api/test_discoveryrule.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def test_positive_update_and_provision_with_rule_priority(

@pytest.mark.tier3
def test_positive_multi_provision_with_rule_limit(
module_target_sat, module_discovery_hostgroup, discovery_location, discovery_org
request, module_target_sat, module_discovery_hostgroup, discovery_location, discovery_org
):
"""Create a discovery rule with certain host limit and try to provision more than the passed limit
Expand All @@ -176,13 +176,12 @@ def test_positive_multi_provision_with_rule_limit(
:CaseImportance: High
"""
for _ in range(2):
discovered_host = module_target_sat.api_factory.create_discovered_host()

discovered_host1 = module_target_sat.api_factory.create_discovered_host()
discovered_host2 = module_target_sat.api_factory.create_discovered_host()
rule = module_target_sat.api.DiscoveryRule(
max_count=1,
hostgroup=module_discovery_hostgroup,
search_=f'name = {discovered_host["name"]}',
search_=f'name = {discovered_host1["name"]}',
location=[discovery_location],
organization=[discovery_org],
priority=1000,
Expand All @@ -191,6 +190,10 @@ def test_positive_multi_provision_with_rule_limit(
assert '1 discovered hosts were provisioned' in result['message']

# Delete discovery rule
rule.delete()
with pytest.raises(HTTPError):
rule.read()
@request.addfinalizer
def _finalize():
rule.delete()
module_target_sat.api.Host(id=discovered_host1['id']).delete()
module_target_sat.api.DiscoveredHost(id=discovered_host2['id']).delete()
with pytest.raises(HTTPError):
rule.read()

0 comments on commit 4cece4a

Please sign in to comment.