@@ -84,7 +84,12 @@ def test_project_cleanup_with_filters(self):
8484 filters = {'created_at' : '2200-01-01' , 'updated_at' : '2200-01-02' }
8585
8686 calls = [
87- mock .call (dry_run = True , status_queue = mock .ANY , filters = filters ),
87+ mock .call (
88+ dry_run = True ,
89+ status_queue = mock .ANY ,
90+ filters = filters ,
91+ skip_resources = None ,
92+ ),
8893 mock .call (dry_run = False , status_queue = mock .ANY , filters = filters ),
8994 ]
9095 self .project_cleanup_mock .assert_has_calls (calls )
@@ -110,7 +115,12 @@ def test_project_cleanup_with_auto_approve(self):
110115
111116 self .sdk_connect_as_project_mock .assert_called_with (self .project )
112117 calls = [
113- mock .call (dry_run = True , status_queue = mock .ANY , filters = {}),
118+ mock .call (
119+ dry_run = True ,
120+ status_queue = mock .ANY ,
121+ filters = {},
122+ skip_resources = None ,
123+ ),
114124 mock .call (dry_run = False , status_queue = mock .ANY , filters = {}),
115125 ]
116126 self .project_cleanup_mock .assert_has_calls (calls )
@@ -135,7 +145,12 @@ def test_project_cleanup_with_project(self):
135145
136146 self .sdk_connect_as_project_mock .assert_called_with (self .project )
137147 calls = [
138- mock .call (dry_run = True , status_queue = mock .ANY , filters = {}),
148+ mock .call (
149+ dry_run = True ,
150+ status_queue = mock .ANY ,
151+ filters = {},
152+ skip_resources = None ,
153+ ),
139154 mock .call (dry_run = False , status_queue = mock .ANY , filters = {}),
140155 ]
141156 self .project_cleanup_mock .assert_has_calls (calls )
@@ -160,7 +175,12 @@ def test_project_cleanup_with_project_abort(self):
160175
161176 self .sdk_connect_as_project_mock .assert_called_with (self .project )
162177 calls = [
163- mock .call (dry_run = True , status_queue = mock .ANY , filters = {}),
178+ mock .call (
179+ dry_run = True ,
180+ status_queue = mock .ANY ,
181+ filters = {},
182+ skip_resources = None ,
183+ ),
164184 ]
165185 self .project_cleanup_mock .assert_has_calls (calls )
166186
@@ -184,7 +204,10 @@ def test_project_cleanup_with_dry_run(self):
184204
185205 self .sdk_connect_as_project_mock .assert_called_with (self .project )
186206 self .project_cleanup_mock .assert_called_once_with (
187- dry_run = True , status_queue = mock .ANY , filters = {}
207+ dry_run = True ,
208+ status_queue = mock .ANY ,
209+ filters = {},
210+ skip_resources = None ,
188211 )
189212
190213 self .assertIsNone (result )
@@ -208,7 +231,42 @@ def test_project_cleanup_with_auth_project(self):
208231
209232 self .sdk_connect_as_project_mock .assert_not_called ()
210233 calls = [
211- mock .call (dry_run = True , status_queue = mock .ANY , filters = {}),
234+ mock .call (
235+ dry_run = True ,
236+ status_queue = mock .ANY ,
237+ filters = {},
238+ skip_resources = None ,
239+ ),
240+ mock .call (dry_run = False , status_queue = mock .ANY , filters = {}),
241+ ]
242+ self .project_cleanup_mock .assert_has_calls (calls )
243+
244+ self .assertIsNone (result )
245+
246+ def test_project_cleanup_with_skip_resource (self ):
247+ skip_resource = "block_storage.backup"
248+ arglist = [
249+ '--project' ,
250+ self .project .id ,
251+ '--skip-resource' ,
252+ skip_resource ,
253+ ]
254+ verifylist = [('skip_resource' , [skip_resource ])]
255+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
256+ result = None
257+
258+ with mock .patch ('sys.stdin' , StringIO ('y' )):
259+ result = self .cmd .take_action (parsed_args )
260+
261+ self .sdk_connect_as_project_mock .assert_called_with (self .project )
262+
263+ calls = [
264+ mock .call (
265+ dry_run = True ,
266+ status_queue = mock .ANY ,
267+ filters = {},
268+ skip_resources = [skip_resource ],
269+ ),
212270 mock .call (dry_run = False , status_queue = mock .ANY , filters = {}),
213271 ]
214272 self .project_cleanup_mock .assert_has_calls (calls )
0 commit comments