Skip to content

Commit

Permalink
pytest conversion for tests/foreman/cli/test_oscap.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Jameer Pathan committed Sep 25, 2020
1 parent 454cc8d commit f99e5be
Show file tree
Hide file tree
Showing 2 changed files with 221 additions and 212 deletions.
30 changes: 30 additions & 0 deletions pytest_fixtures/api_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from wrapanapi import GoogleCloudSystem

from robottelo import ssh
from robottelo.cli.ansible import Ansible
from robottelo.constants import AZURERM_RG_DEFAULT
from robottelo.constants import AZURERM_RHEL7_FT_BYOS_IMG_URN
from robottelo.constants import AZURERM_RHEL7_FT_CUSTOM_IMG_URN
Expand Down Expand Up @@ -411,7 +412,36 @@ def oscap_content_path():
return local_file


@pytest.fixture(scope="session")
def import_ansible_roles(default_smart_proxy):
""" Import ansible roles to default_smart_proxy for tests"""
Ansible.roles_import({'proxy-id': default_smart_proxy.id})
Ansible.variables_import({'proxy-id': default_smart_proxy.id})


@pytest.fixture(scope='session')
def default_pxetemplate():
pxe_template = entities.ProvisioningTemplate().search(query={'search': DEFAULT_PXE_TEMPLATE})
return pxe_template[0].read()


@pytest.fixture(scope='module')
def module_viewer_user(module_org):
"""Custom user with viewer role for tests validating visibility of entities or fields created
by some other user. Created only when accessed, unlike `module_user`.
"""
viewer_role = entities.Role().search(query={'search': 'name="Viewer"'})[0]
default_loc_id = (
entities.Location().search(query={'search': 'name="{}"'.format(DEFAULT_LOC)})[0].id
)
custom_password = gen_string('alphanumeric')
custom_user = entities.User(
admin=False,
default_organization=module_org,
location=[default_loc_id],
organization=[module_org],
role=[viewer_role],
password=custom_password,
).create()
custom_user.password = custom_password
return custom_user
Loading

0 comments on commit f99e5be

Please sign in to comment.