File tree Expand file tree Collapse file tree 3 files changed +42
-4
lines changed Expand file tree Collapse file tree 3 files changed +42
-4
lines changed Original file line number Diff line number Diff line change @@ -94,6 +94,7 @@ def __call__(self) -> Any:
94
94
return self .do_custom ()
95
95
96
96
def do_custom (self ) -> Any :
97
+ class_instance : Union [gitlab .base .RESTManager , gitlab .base .RESTObject ]
97
98
in_obj = cli .custom_actions [self .cls_name ][self .action ][2 ]
98
99
99
100
# Get the object (lazy), then act
@@ -106,11 +107,12 @@ def do_custom(self) -> Any:
106
107
if TYPE_CHECKING :
107
108
assert isinstance (self .cls ._id_attr , str )
108
109
data [self .cls ._id_attr ] = self .args .pop (self .cls ._id_attr )
109
- obj = self .cls (self .mgr , data )
110
- method_name = self .action .replace ("-" , "_" )
111
- return getattr (obj , method_name )(** self .args )
110
+ class_instance = self .cls (self .mgr , data )
112
111
else :
113
- return getattr (self .mgr , self .action )(** self .args )
112
+ class_instance = self .mgr
113
+
114
+ method_name = self .action .replace ("-" , "_" )
115
+ return getattr (class_instance , method_name )(** self .args )
114
116
115
117
def do_project_export_download (self ) -> None :
116
118
try :
Original file line number Diff line number Diff line change @@ -33,3 +33,12 @@ def resp_get_project():
33
33
"content_type" : "application/json" ,
34
34
"status" : 200 ,
35
35
}
36
+
37
+
38
+ @pytest .fixture
39
+ def resp_delete_registry_tags_in_bulk ():
40
+ return {
41
+ "method" : responses .DELETE ,
42
+ "url" : f"{ DEFAULT_URL } /api/v4/projects/1/registry/repositories/1/tags" ,
43
+ "status" : 202 ,
44
+ }
Original file line number Diff line number Diff line change
1
+ import pytest
2
+ import responses
3
+
4
+
5
+ @pytest .mark .script_launch_mode ("inprocess" )
6
+ @responses .activate
7
+ def test_project_registry_delete_in_bulk (
8
+ script_runner , resp_delete_registry_tags_in_bulk
9
+ ):
10
+ responses .add (** resp_delete_registry_tags_in_bulk )
11
+ cmd = [
12
+ "gitlab" ,
13
+ "project-registry-tag" ,
14
+ "delete-in-bulk" ,
15
+ "--project-id" ,
16
+ "1" ,
17
+ "--repository-id" ,
18
+ "1" ,
19
+ "--name-regex-delete" ,
20
+ "^.*dev.*$" ,
21
+ # TODO: remove `name` after deleting without ID is possible
22
+ # See #849 and #1631
23
+ "--name" ,
24
+ ".*" ,
25
+ ]
26
+ ret = ret = script_runner .run (* cmd )
27
+ assert ret .success
You can’t perform that action at this time.
0 commit comments