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:
9494 return self .do_custom ()
9595
9696 def do_custom (self ) -> Any :
97+ class_instance : Union [gitlab .base .RESTManager , gitlab .base .RESTObject ]
9798 in_obj = cli .custom_actions [self .cls_name ][self .action ][2 ]
9899
99100 # Get the object (lazy), then act
@@ -106,11 +107,12 @@ def do_custom(self) -> Any:
106107 if TYPE_CHECKING :
107108 assert isinstance (self .cls ._id_attr , str )
108109 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 )
112111 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 )
114116
115117 def do_project_export_download (self ) -> None :
116118 try :
Original file line number Diff line number Diff line change @@ -33,3 +33,12 @@ def resp_get_project():
3333 "content_type" : "application/json" ,
3434 "status" : 200 ,
3535 }
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