Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove nailgun.entities imports in tests/foreman/longrun #15220

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 17 additions & 18 deletions tests/foreman/longrun/test_inc_updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

from datetime import datetime, timedelta

from nailgun import entities
import pytest

from robottelo.config import settings
Expand All @@ -33,10 +32,10 @@


@pytest.fixture(scope='module')
def module_lce_library(module_sca_manifest_org):
def module_lce_library(module_target_sat, module_sca_manifest_org):
"""Returns the Library lifecycle environment from chosen organization"""
return (
entities.LifecycleEnvironment()
module_target_sat.api.LifecycleEnvironment()
.search(
query={
'search': f'name={ENVIRONMENT} and ' f'organization_id={module_sca_manifest_org.id}'
Expand All @@ -47,13 +46,15 @@ def module_lce_library(module_sca_manifest_org):


@pytest.fixture(scope='module')
def dev_lce(module_sca_manifest_org):
return entities.LifecycleEnvironment(name='DEV', organization=module_sca_manifest_org).create()
def dev_lce(module_target_sat, module_sca_manifest_org):
return module_target_sat.api.LifecycleEnvironment(
name='DEV', organization=module_sca_manifest_org
).create()


@pytest.fixture(scope='module')
def qe_lce(module_sca_manifest_org, dev_lce):
return entities.LifecycleEnvironment(
def qe_lce(module_target_sat, module_sca_manifest_org, dev_lce):
return module_target_sat.api.LifecycleEnvironment(
name='QE', prior=dev_lce, organization=module_sca_manifest_org
).create()

Expand Down Expand Up @@ -86,9 +87,9 @@ def custom_repo(module_sca_manifest_org, module_target_sat):


@pytest.fixture(scope='module')
def module_cv(module_sca_manifest_org, sat_client_repo, custom_repo):
def module_cv(module_target_sat, module_sca_manifest_org, sat_client_repo, custom_repo):
"""Publish both repos into module CV"""
module_cv = entities.ContentView(
module_cv = module_target_sat.api.ContentView(
organization=module_sca_manifest_org,
repository=[sat_client_repo.id, custom_repo.id],
).create()
Expand All @@ -101,7 +102,7 @@ def module_ak(
module_sca_manifest_org, module_cv, custom_repo, module_lce_library, module_target_sat
):
"""Create a module AK in Library LCE"""
ak = entities.ActivationKey(
ak = module_target_sat.api.ActivationKey(
content_view=module_cv,
environment=module_lce_library,
organization=module_sca_manifest_org,
Expand Down Expand Up @@ -158,19 +159,14 @@ def host(
)
# Add filter of type include but do not include anything.
# this will hide all RPMs from selected erratum before publishing.
entities.RPMContentViewFilter(
module_target_sat.api.RPMContentViewFilter(
content_view=module_cv, inclusion=True, name='Include Nothing'
).create()
module_cv.publish()
module_cv = module_cv.read()
return rhel7_contenthost_module


def get_applicable_errata(repo):
"""Retrieves applicable errata for the given repo"""
return entities.Errata(repository=repo).search(query={'errata_restrict_applicable': True})


@pytest.mark.tier4
@pytest.mark.upgrade
def test_positive_noapply_api(
Expand All @@ -194,8 +190,11 @@ def test_positive_noapply_api(
cvv = versions[-1].read()
cvv.promote(data={'environment_ids': dev_lce.id})

# Get the applicable errata
errata_list = get_applicable_errata(custom_repo)
# Get the applicable errata for the given repo
errata_list = module_target_sat.api.Errata(repository=custom_repo).search(
query={'errata_restrict_applicable': True}
)

assert len(errata_list) > 0

# Apply incremental update using the first applicable errata
Expand Down
15 changes: 9 additions & 6 deletions tests/foreman/longrun/test_oscap.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

from broker import Broker
from fauxfactory import gen_string
from nailgun import entities
import pytest

from robottelo.config import settings
Expand Down Expand Up @@ -69,15 +68,19 @@ def default_proxy(module_target_sat):


@pytest.fixture(scope='module')
def lifecycle_env(module_org):
def lifecycle_env(module_target_sat, module_org):
"""Create lifecycle environment"""
return entities.LifecycleEnvironment(organization=module_org, name=gen_string('alpha')).create()
return module_target_sat.api.LifecycleEnvironment(
organization=module_org, name=gen_string('alpha')
).create()


@pytest.fixture(scope='module')
def content_view(module_org):
def content_view(module_target_sat, module_org):
"""Create content view"""
return entities.ContentView(organization=module_org, name=gen_string('alpha')).create()
return module_target_sat.api.ContentView(
organization=module_org, name=gen_string('alpha')
).create()


@pytest.fixture(scope='module', autouse=True)
Expand All @@ -90,7 +93,7 @@ def activation_key(module_target_sat, module_org, lifecycle_env, content_view):
]

for repo in repo_values:
activation_key = entities.ActivationKey(
activation_key = module_target_sat.api.ActivationKey(
name=repo.get('akname'), environment=lifecycle_env, organization=module_org
).create()
# Setup org for a custom repo for RHEL6, RHEL7 and RHEL8.
Expand Down
Loading