Skip to content

Commit

Permalink
Fix error in safe_calls_only without fake_mode
Browse files Browse the repository at this point in the history
When fake mode was not explicitely selected complaining about unsafe
calls in fake_mode is not nice. Instead, we fall back to the original
error message in that case.

fixes #1037

(cherry picked from commit 00ede19)
  • Loading branch information
mdellweg committed Aug 14, 2024
1 parent f2539d9 commit 4093e90
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES/pulp-glue/1037.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed an error where safemode wrongly complained to be in `fake_mode`.
7 changes: 5 additions & 2 deletions pulp-glue/pulp_glue/common/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,11 @@ def call(
body=body,
validate_body=validate_body,
)
except UnsafeCallError:
raise NotImplementedFake(f"Operation {operation_id} was attempted in fake mode.")
except UnsafeCallError as e:
if self.fake_mode:
raise NotImplementedFake(f"Operation {operation_id} was attempted in fake mode.")
else:
raise PulpException(str(e))
except OpenAPIError as e:
raise PulpException(str(e))
except HTTPError as e:
Expand Down
6 changes: 5 additions & 1 deletion pulp-glue/pulp_glue/core/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,11 @@ def cleanup(self, body: t.Optional[t.Dict[str, t.Any]] = None) -> t.Any:
else:
if body:
self.pulp_ctx.needs_plugin(PluginRequirement("core", specifier=">=3.14.0"))
result = self.pulp_ctx.call("orphans_delete")
if not self.pulp_ctx.fake_mode:
result = self.pulp_ctx.call("orphans_delete")
else:
# Do we need something better?
result = {}
return result


Expand Down

0 comments on commit 4093e90

Please sign in to comment.