Skip to content

Commit

Permalink
Style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lhellebr committed Jun 19, 2023
1 parent 801ee1b commit c1774d7
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions tests/foreman/api/test_ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
"""
import pytest
from fauxfactory import gen_string

from nailgun import entities
from nailgun.config import ServerConfig

from robottelo.config import settings


Expand Down Expand Up @@ -257,7 +257,7 @@ def test_add_and_remove_ansible_role_hostgroup(target_sat):
assert len(host_roles) == 0


@pytest.mark.rhel_ver_match('[7]')
@pytest.mark.rhel_ver_match('[678]')
@pytest.mark.tier2
def test_positive_read_facts_with_filter(target_sat, module_org, module_location, rex_contenthost):
"""
Expand All @@ -269,29 +269,33 @@ def test_positive_read_facts_with_filter(target_sat, module_org, module_location
1. Create a role with a host view filtered
2. Create a user with that role
3. Create a host
3. Run Ansible roles on a host
4. Using API, read Ansible facts of that host
4. Run Ansible roles on a host
5. Using API, read Ansible facts of that host
:expectedresults:
1. Ansible facts returned
:expectedresults: Ansible facts returned
:BZ: 1699188
:customerscenario: true
"""
api = target_sat.api

role = api.Role(name=gen_string('alpha'), location=[module_location], organization=[module_org]).create()
# assign view_hosts (with a filter, to test BZ 1699188), view_hostgroups, view_facts permissions to the role
permission_hosts = permissions = api.Permission().search(query={'search': 'name="view_hosts"'})
permission_hostgroups = permissions = api.Permission().search(query={'search': 'name="view_hostgroups"'})
permission_facts = permissions = api.Permission().search(query={'search': 'name="view_facts"'})
role = api.Role(
name=gen_string('alpha'), location=[module_location], organization=[module_org]
).create()
# assign view_hosts (with a filter, to test BZ 1699188),
# view_hostgroups, view_facts permissions to the role
permission_hosts = api.Permission().search(query={'search': 'name="view_hosts"'})
permission_hostgroups = api.Permission().search(query={'search': 'name="view_hostgroups"'})
permission_facts = api.Permission().search(query={'search': 'name="view_facts"'})
api.Filter(permission=permission_hosts, search='name != nonexistent', role=role).create()
api.Filter(permission=permission_hostgroups, role=role).create()
api.Filter(permission=permission_facts, role=role).create()

password = gen_string('alpha')
user = api.User(role=[role], password=password, location=[module_location], organization=[module_org]).create()
user = api.User(
role=[role], password=password, location=[module_location], organization=[module_org]
).create()

host = api.Host().search(query={'search': f'name={rex_contenthost.hostname}'})[0]
host_id = host.id
Expand All @@ -305,7 +309,7 @@ def test_positive_read_facts_with_filter(target_sat, module_org, module_location
# get facts through API
facts = host.get_facts()
assert 'subtotal' in facts
assert facts['subtotal']==1
assert facts['subtotal'] == 1
assert 'results' in facts
assert rex_contenthost.hostname in facts['results']
assert len(facts['results'][rex_contenthost.hostname])>0
assert len(facts['results'][rex_contenthost.hostname]) > 0

0 comments on commit c1774d7

Please sign in to comment.