33import 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+
617def test_auth_from_config (gl ,temp_dir ):
718"""Test token authentication from config file"""
819test_gitlab = gitlab .Gitlab .from_config (
@@ -12,13 +23,13 @@ def test_auth_from_config(gl, temp_dir):
1223assert 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 ):
1627msg = gl .broadcastmessages .create ({"message" :"this is the message" })
1728msg .color = "#444444"
1829msg .save ()
1930msg_id = msg .id
2031
21- msg = gl .broadcastmessages .list (get_all = True )[0 ]
32+ msg = gl .broadcastmessages .list (** get_all_kwargs )[0 ]
2233assert msg .color == "#444444"
2334
2435msg = gl .broadcastmessages .get (msg_id )
@@ -85,14 +96,14 @@ def test_template_dockerfile(gl):
8596assert 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 )
90101gitignore = gl .gitignores .get ("Node" )
91102assert 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 )
96107gitlabciyml = gl .gitlabciymls .get ("Nodejs" )
97108assert gitlabciyml .content is not None
98109
@@ -113,11 +124,11 @@ def test_hooks(gl):
113124assert 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 )
118129assert namespace
119130
120- namespace = gl .namespaces .list (search = "root" ,get_all = True )[0 ]
131+ namespace = gl .namespaces .list (search = "root" ,** get_all_kwargs )[0 ]
121132assert namespace .kind == "user"
122133
123134
@@ -216,9 +227,9 @@ def test_list_all_false_nowarning(gl, recwarn):
216227assert 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 )
222233assert not recwarn
223234assert len (items )> 20
224235