Skip to content

Commit

Permalink
[6.14.z] non existent APIResponseError (#17509)
Browse files Browse the repository at this point in the history
non existent APIResponseError (#17406)

(cherry picked from commit 233873c)

Co-authored-by: Peter Ondrejka <[email protected]>
  • Loading branch information
Satellite-QE and pondrejk authored Feb 5, 2025
1 parent 3a08611 commit f8071ab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
4 changes: 4 additions & 0 deletions robottelo/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
"""Custom Errors for Robottelo"""


class APIResponseError(Exception):
"""Indicates wrong API response"""


class GCECertNotFoundError(Exception):
"""An exception to raise when GCE Cert json is not available for creating GCE CR"""

Expand Down
13 changes: 6 additions & 7 deletions robottelo/host_helpers/api_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
DEFAULT_ARCHITECTURE,
REPO_TYPE,
)
from robottelo.exceptions import APIResponseError
from robottelo.host_helpers.repository_mixins import initiate_repo_helpers


Expand Down Expand Up @@ -206,14 +207,14 @@ def create_role_permissions(
query={'search': f'name="{name}"'}
)
if not result:
raise self._satellite.api.APIResponseError(f'permission "{name}" not found')
raise APIResponseError(f'permission "{name}" not found')
if len(result) > 1:
raise self._satellite.api.APIResponseError(
raise APIResponseError(
f'found more than one entity for permission "{name}"'
)
entity_permission = result[0]
if entity_permission.name != name:
raise self._satellite.api.APIResponseError(
raise APIResponseError(
'the returned permission is different from the'
f' requested one "{entity_permission.name} != {name}"'
)
Expand All @@ -229,9 +230,7 @@ def create_role_permissions(
query={'per_page': '350', 'search': f'resource_type="{resource_type}"'}
)
if not resource_type_permissions_entities:
raise self._satellite.api.APIResponseError(
f'resource type "{resource_type}" permissions not found'
)
raise APIResponseError(f'resource type "{resource_type}" permissions not found')

permissions_entities = [
entity
Expand All @@ -243,7 +242,7 @@ def create_role_permissions(
permissions_entities_names = {entity.name for entity in permissions_entities}
not_found_names = set(permissions_name).difference(permissions_entities_names)
if not_found_names:
raise self._satellite.api.APIResponseError(
raise APIResponseError(
f'permissions names entities not found "{not_found_names}"'
)
self._satellite.api.Filter(
Expand Down

0 comments on commit f8071ab

Please sign in to comment.