Skip to content

Commit 201298d

Browse files
nejchJohnVillalovos
authored andcommitted
test(functional): use both get_all and all in list() tests
1 parent 7c71d5d commit 201298d

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

tests/functional/api/test_gitlab.py

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@
33
import gitlab
44

55

6+
@pytest.fixture(
7+
scope="session",
8+
params=[{"get_all": True}, {"all": True}],
9+
ids=["get_all=True", "all=True"],
10+
)
11+
def get_all_kwargs(request):
12+
"""A tiny parametrized fixture to inject both `get_all=True` and
13+
`all=True` to ensure they behave the same way for pagination."""
14+
return request.param
15+
16+
617
def test_auth_from_config(gl, temp_dir):
718
"""Test token authentication from config file"""
819
test_gitlab = gitlab.Gitlab.from_config(
@@ -12,13 +23,13 @@ def test_auth_from_config(gl, temp_dir):
1223
assert isinstance(test_gitlab.user, gitlab.v4.objects.CurrentUser)
1324

1425

15-
def test_broadcast_messages(gl):
26+
def test_broadcast_messages(gl, get_all_kwargs):
1627
msg = gl.broadcastmessages.create({"message": "this is the message"})
1728
msg.color = "#444444"
1829
msg.save()
1930
msg_id = msg.id
2031

21-
msg = gl.broadcastmessages.list(get_all=True)[0]
32+
msg = gl.broadcastmessages.list(**get_all_kwargs)[0]
2233
assert msg.color == "#444444"
2334

2435
msg = gl.broadcastmessages.get(msg_id)
@@ -85,14 +96,14 @@ def test_template_dockerfile(gl):
8596
assert dockerfile.content is not None
8697

8798

88-
def test_template_gitignore(gl):
89-
assert gl.gitignores.list(get_all=True)
99+
def test_template_gitignore(gl, get_all_kwargs):
100+
assert gl.gitignores.list(**get_all_kwargs)
90101
gitignore = gl.gitignores.get("Node")
91102
assert gitignore.content is not None
92103

93104

94-
def test_template_gitlabciyml(gl):
95-
assert gl.gitlabciymls.list(get_all=True)
105+
def test_template_gitlabciyml(gl, get_all_kwargs):
106+
assert gl.gitlabciymls.list(**get_all_kwargs)
96107
gitlabciyml = gl.gitlabciymls.get("Nodejs")
97108
assert gitlabciyml.content is not None
98109

@@ -113,11 +124,11 @@ def test_hooks(gl):
113124
assert hook not in gl.hooks.list()
114125

115126

116-
def test_namespaces(gl):
117-
namespace = gl.namespaces.list(get_all=True)
127+
def test_namespaces(gl, get_all_kwargs):
128+
namespace = gl.namespaces.list(**get_all_kwargs)
118129
assert namespace
119130

120-
namespace = gl.namespaces.list(search="root", get_all=True)[0]
131+
namespace = gl.namespaces.list(search="root", **get_all_kwargs)[0]
121132
assert namespace.kind == "user"
122133

123134

@@ -216,9 +227,9 @@ def test_list_all_false_nowarning(gl, recwarn):
216227
assert not recwarn
217228

218229

219-
def test_list_all_true_nowarning(gl, recwarn):
230+
def test_list_all_true_nowarning(gl, get_all_kwargs, recwarn):
220231
"""Using `get_all=True` will disable the warning"""
221-
items = gl.gitlabciymls.list(get_all=True)
232+
items = gl.gitlabciymls.list(**get_all_kwargs)
222233
assert not recwarn
223234
assert len(items) > 20
224235

0 commit comments

Comments
 (0)