From 7506eb8e0c459494bdb4ec47de2e18a2a953d727 Mon Sep 17 00:00:00 2001 From: "Dr. Jens Harbott" Date: Tue, 15 Nov 2022 08:57:26 +0100 Subject: Add auto-approve option to project cleanup Sometimes it is useful to be able to use the project cleanup function in scripts and having to add "echo y | openstack" isn't really nice. Signed-off-by: Dr. Jens Harbott Change-Id: I3ded9982769b4568b6dcfc49bc31ba67a6227839 --- .../tests/unit/common/test_project_cleanup.py | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'openstackclient/tests') diff --git a/openstackclient/tests/unit/common/test_project_cleanup.py b/openstackclient/tests/unit/common/test_project_cleanup.py index d235aeb0..50c434b9 100644 --- a/openstackclient/tests/unit/common/test_project_cleanup.py +++ b/openstackclient/tests/unit/common/test_project_cleanup.py @@ -85,6 +85,32 @@ class TestProjectCleanup(TestProjectCleanupBase): self.assertIsNone(result) + def test_project_cleanup_with_auto_approve(self): + arglist = [ + '--project', self.project.id, + '--auto-approve', + ] + verifylist = [ + ('dry_run', False), + ('auth_project', False), + ('project', self.project.id), + ('auto_approve', True), + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + result = None + + result = self.cmd.take_action(parsed_args) + + self.sdk_connect_as_project_mock.assert_called_with( + self.project) + calls = [ + mock.call(dry_run=True, status_queue=mock.ANY, filters={}), + mock.call(dry_run=False, status_queue=mock.ANY, filters={}) + ] + self.project_cleanup_mock.assert_has_calls(calls) + + self.assertIsNone(result) + def test_project_cleanup_with_project(self): arglist = [ '--project', self.project.id, -- cgit v1.2.1