Skip to content

Commit

Permalink
Remove cli.factory dependencies from the repo (SatelliteQE#11544)
Browse files Browse the repository at this point in the history
Remove cli_factory
  • Loading branch information
shweta83 committed Apr 10, 2024
1 parent 04136ae commit 21f7636
Show file tree
Hide file tree
Showing 92 changed files with 5,241 additions and 6,487 deletions.
5 changes: 2 additions & 3 deletions pytest_fixtures/component/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from nailgun import entities
import pytest

from robottelo.cli.factory import setup_org_for_a_rh_repo
from robottelo.constants import DEFAULT_CV, ENVIRONMENT, PRDS, REPOS, REPOSET


Expand All @@ -24,7 +23,7 @@ def module_model():

@pytest.mark.skip_if_not_set('clients', 'fake_manifest')
@pytest.fixture(scope="module")
def setup_rhst_repo():
def setup_rhst_repo(module_target_sat):
"""Prepare Satellite tools repository for usage in specified organization"""
org = entities.Organization().create()
cv = entities.ContentView(organization=org).create()
Expand All @@ -34,7 +33,7 @@ def setup_rhst_repo():
organization=org,
).create()
repo_name = 'rhst7'
setup_org_for_a_rh_repo(
module_target_sat.cli_factory.setup_org_for_a_rh_repo(
{
'product': PRDS['rhel'],
'repository-set': REPOSET[repo_name],
Expand Down
2 changes: 1 addition & 1 deletion pytest_fixtures/component/maintain.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def setup_sync_plan(request, sat_maintain):
"""
org = sat_maintain.api.Organization().create()
# Setup sync-plan
new_sync_plan = sat_maintain.cli_factory.make_sync_plan(
new_sync_plan = sat_maintain.cli_factory.sync_plan(
{
'enabled': 'true',
'interval': 'weekly',
Expand Down
7 changes: 4 additions & 3 deletions pytest_fixtures/component/oscap.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from nailgun import entities
import pytest

from robottelo.cli.factory import make_scapcontent
from robottelo.config import robottelo_tmp_dir, settings
from robottelo.constants import OSCAP_PROFILE, OSCAP_TAILORING_FILE, DataFile

Expand All @@ -29,9 +28,11 @@ def oscap_content_path(session_target_sat):


@pytest.fixture(scope="module")
def scap_content(import_ansible_roles):
def scap_content(import_ansible_roles, module_target_sat):
title = f"rhel-content-{gen_string('alpha')}"
scap_info = make_scapcontent({'title': title, 'scap-file': f'{settings.oscap.content_path}'})
scap_info = module_target_sat.cli_factory.scapcontent(
{'title': title, 'scap-file': f'{settings.oscap.content_path}'}
)
scap_id = scap_info['id']
scap_info = entities.ScapContents(id=scap_id).read()

Expand Down
52 changes: 2 additions & 50 deletions robottelo/cli/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,59 +6,11 @@
from robottelo import ssh
from robottelo.cli import hammer
from robottelo.config import settings
from robottelo.exceptions import CLIDataBaseError, CLIError, CLIReturnCodeError
from robottelo.logging import logger
from robottelo.utils.ssh import get_client


class CLIError(Exception):
"""Indicates that a CLI command could not be run."""


class CLIBaseError(Exception):
"""Indicates that a CLI command has finished with return code different
from zero.
:param status: CLI command return code
:param stderr: contents of the ``stderr``
:param msg: explanation of the error
"""

def __init__(self, status, stderr, msg):
self.status = status
self.stderr = stderr
self.msg = msg
super().__init__(msg)
self.message = msg

def __str__(self):
"""Include class name, status, stderr and msg to string repr so
assertRaisesRegexp can be used to assert error present on any
attribute
"""
return repr(self)

def __repr__(self):
"""Include class name status, stderr and msg to improve logging"""
return '{}(status={!r}, stderr={!r}, msg={!r}'.format(
type(self).__name__, self.status, self.stderr, self.msg
)


class CLIReturnCodeError(CLIBaseError):
"""Error to be raised when an error occurs due to some validation error
when execution hammer cli.
See: https://github.com/SatelliteQE/robottelo/issues/3790 for more details
"""


class CLIDataBaseError(CLIBaseError):
"""Error to be raised when an error occurs due to some missing parameter
which cause a data base error on hammer
See: https://github.com/SatelliteQE/robottelo/issues/3790 for more details
"""


class Base:
"""Base class for hammer CLI interaction
Expand All @@ -84,7 +36,7 @@ def _handle_response(cls, response, ignore_stderr=None):
:param ignore_stderr: indicates whether to throw a warning in logs if
``stderr`` is not empty.
:returns: contents of ``stdout``.
:raises robottelo.cli.base.CLIReturnCodeError: If return code is
:raises robottelo.exceptions.CLIReturnCodeError: If return code is
different from zero.
"""
if isinstance(response.stderr, tuple):
Expand Down
Loading

0 comments on commit 21f7636

Please sign in to comment.