3
3
import gitlab
4
4
5
5
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
+
6
17
def test_auth_from_config (gl , temp_dir ):
7
18
"""Test token authentication from config file"""
8
19
test_gitlab = gitlab .Gitlab .from_config (
@@ -12,13 +23,13 @@ def test_auth_from_config(gl, temp_dir):
12
23
assert isinstance (test_gitlab .user , gitlab .v4 .objects .CurrentUser )
13
24
14
25
15
- def test_broadcast_messages (gl ):
26
+ def test_broadcast_messages (gl , get_all_kwargs ):
16
27
msg = gl .broadcastmessages .create ({"message" : "this is the message" })
17
28
msg .color = "#444444"
18
29
msg .save ()
19
30
msg_id = msg .id
20
31
21
- msg = gl .broadcastmessages .list (get_all = True )[0 ]
32
+ msg = gl .broadcastmessages .list (** get_all_kwargs )[0 ]
22
33
assert msg .color == "#444444"
23
34
24
35
msg = gl .broadcastmessages .get (msg_id )
@@ -85,14 +96,14 @@ def test_template_dockerfile(gl):
85
96
assert dockerfile .content is not None
86
97
87
98
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 )
90
101
gitignore = gl .gitignores .get ("Node" )
91
102
assert gitignore .content is not None
92
103
93
104
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 )
96
107
gitlabciyml = gl .gitlabciymls .get ("Nodejs" )
97
108
assert gitlabciyml .content is not None
98
109
@@ -113,11 +124,11 @@ def test_hooks(gl):
113
124
assert hook not in gl .hooks .list ()
114
125
115
126
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 )
118
129
assert namespace
119
130
120
- namespace = gl .namespaces .list (search = "root" , get_all = True )[0 ]
131
+ namespace = gl .namespaces .list (search = "root" , ** get_all_kwargs )[0 ]
121
132
assert namespace .kind == "user"
122
133
123
134
@@ -216,9 +227,9 @@ def test_list_all_false_nowarning(gl, recwarn):
216
227
assert not recwarn
217
228
218
229
219
- def test_list_all_true_nowarning (gl , recwarn ):
230
+ def test_list_all_true_nowarning (gl , get_all_kwargs , recwarn ):
220
231
"""Using `get_all=True` will disable the warning"""
221
- items = gl .gitlabciymls .list (get_all = True )
232
+ items = gl .gitlabciymls .list (** get_all_kwargs )
222
233
assert not recwarn
223
234
assert len (items ) > 20
224
235
0 commit comments