|
| 1 | +# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 2 | +# not use this file except in compliance with the License. You may obtain |
| 3 | +# a copy of the License at |
| 4 | +# |
| 5 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | +# |
| 7 | +# Unless required by applicable law or agreed to in writing, software |
| 8 | +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 9 | +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 10 | +# License for the specific language governing permissions and limitations |
| 11 | +# under the License. |
| 12 | +# |
| 13 | + |
| 14 | +from unittest import mock |
| 15 | + |
| 16 | +import fixtures |
| 17 | + |
| 18 | +from openstackclient.common import cloud |
| 19 | +from openstackclient.tests.unit import utils |
| 20 | + |
| 21 | + |
| 22 | +class TestDeleteCloudCache(utils.TestCommand): |
| 23 | + def setUp(self): |
| 24 | + super().setUp() |
| 25 | + |
| 26 | + self.cmd = cloud.DeleteCloudCache(self.app, None) |
| 27 | + # The fake client manager has no cloud region of its own. |
| 28 | + self.cloud_region = self.useFixture( |
| 29 | + fixtures.MockPatchObject( |
| 30 | + self.app.client_manager, |
| 31 | + '_cli_options', |
| 32 | + mock.Mock(), |
| 33 | + create=True, |
| 34 | + ) |
| 35 | + ).mock |
| 36 | + |
| 37 | + def test_delete(self): |
| 38 | + parsed_args = self.check_parser(self.cmd, [], []) |
| 39 | + |
| 40 | + self.cmd.take_action(parsed_args) |
| 41 | + |
| 42 | + self.cloud_region.clear_auth_cache.assert_called_once_with() |
| 43 | + |
| 44 | + def test_does_not_authenticate(self): |
| 45 | + # Authenticating in order to discard the credential that would be used |
| 46 | + # to do it is pointless, and impossible when that credential is the |
| 47 | + # broken thing being cleared. |
| 48 | + self.assertFalse(self.cmd.auth_required) |
0 commit comments