Skip to content

Commit ddec1a3

Browse files
committed
test: fix reset_gitlab fixture to delete descendant groups first
1 parent 789de32 commit ddec1a3

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

tests/functional/api/test_statistics.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
"""
44

55

6-
from tests.functional.conftest import reset_gitlab
7-
8-
9-
def test_get_statistics(gl):
6+
def test_get_statistics(gl, reset_gitlab):
107

118
# delete resources created from other functional tests to reset application statistics
129
reset_gitlab(gl)

tests/functional/conftest.py

+13-9
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,23 @@ def reset_gitlab(gl: gitlab.Gitlab) -> None:
9494
helpers.safe_delete(deploy_token)
9595
logging.info(f"Deleting project: {project.path_with_namespace!r}")
9696
helpers.safe_delete(project)
97-
97+
9898
full_paths = [group.full_path for group in gl.groups.list()]
9999
logging.info(f"Groups to be deleted: {full_paths}")
100100
for group in gl.groups.list():
101101
logging.info(f"Current group: {group.full_path!r}, group_id: {group.get_id()}")
102-
for deploy_token in group.deploytokens.list():
103-
logging.info(
104-
f"Deleting deploy token: {deploy_token.username!r} in "
105-
f"group: {group.path_with_namespace!r}"
106-
)
107-
helpers.safe_delete(deploy_token)
108-
logging.info(f"Deleting group: {group.full_path!r}")
109-
helpers.safe_delete(group)
102+
descendant_full_paths = [group.full_path for group in group.descendant_groups.list(order_by="id", sort="desc")]
103+
logging.info(f"Descendant groups to be deleted: {descendant_full_paths}")
104+
for descendant_group in group.descendant_groups.list(order_by="id", sort="desc"):
105+
logging.info(f"Current group: {descendant_group.full_path!r}, group_id: {descendant_group.get_id()}")
106+
for deploy_token in group.deploytokens.list():
107+
logging.info(
108+
f"Deleting deploy token: {deploy_token.username!r} in "
109+
f"group: {group.path_with_namespace!r}"
110+
)
111+
helpers.safe_delete(deploy_token)
112+
logging.info(f"Deleting group: {group.full_path!r}")
113+
helpers.safe_delete(group)
110114
for topic in gl.topics.list():
111115
logging.info(f"Deleting topic: {topic.name!r}")
112116
helpers.safe_delete(topic)

0 commit comments

Comments
 (0)