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 6a832f8
Show file tree
Hide file tree
Showing 2 changed files with 222 additions and 212 deletions.
31 changes: 31 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 All @@ -21,6 +22,7 @@
from robottelo.constants import DEFAULT_PXE_TEMPLATE
from robottelo.constants import DEFAULT_TEMPLATE
from robottelo.constants import ENVIRONMENT
from robottelo.constants import OSCAP_PROFILE
from robottelo.constants import RHEL_6_MAJOR_VERSION
from robottelo.constants import RHEL_7_MAJOR_VERSION
from robottelo.helpers import download_gce_cert
Expand Down Expand Up @@ -411,7 +413,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 6a832f8

Please sign in to comment.