Skip to content

Commit b30e607

Browse files
authored
Support differing operation tag and undo tag (#1317)
* add base tag to operation id, use it to replace Api object if undo tag differs from base tag * change undo tags to single string
1 parent c838c61 commit b30e607

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

tests/conftest.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,12 @@ def undo_operations():
342342
version = f.parent.parent.name
343343
with f.open() as fp:
344344
data = json.load(fp)
345-
result[version] = {
346-
snake_case(operation_id): settings.get("undo") for operation_id, settings in data.items()
347-
}
345+
result[version] = {}
346+
for operation_id, settings in data.items():
347+
undo_settings = settings.get("undo")
348+
undo_settings["base_tag"] = settings.get("tag")
349+
result[version][snake_case(operation_id)] = undo_settings
350+
348351

349352
return result
350353

@@ -511,6 +514,15 @@ def cleanup(api, version, operation_id, response, client=client):
511514
if operation["type"] != "unsafe":
512515
return
513516

517+
# If Undo tag is not the same as the the operation tag.
518+
# For example, Service Accounts use the DisableUser operation to undo, which is part of Users.
519+
if "tag" in operation and operation["base_tag"] != operation["tag"]:
520+
undo_tag = operation["tag"]
521+
undo_name = undo_tag.replace(" ", "")
522+
undo_module_name = snake_case(undo_tag)
523+
undo_package = importlib.import_module(f"{package_name}.api.{undo_module_name}_api")
524+
api = getattr(undo_package, undo_name + "Api")(client)
525+
514526
operation_name = snake_case(operation["operationId"])
515527
method = getattr(api, operation_name)
516528
kwargs = {}

0 commit comments

Comments
 (0)