|
| 1 | +# Copyright 2015 Mirantis, Inc. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 | +# not use this file except in compliance with the License. You may obtain |
| 5 | +# a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 | +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | +# License for the specific language governing permissions and limitations |
| 13 | +# under the License. |
| 14 | +# |
| 15 | + |
| 16 | +from openstackclient.compute.v2 import service |
| 17 | +from openstackclient.tests.compute.v2 import fakes as compute_fakes |
| 18 | + |
| 19 | + |
| 20 | +class TestService(compute_fakes.TestComputev2): |
| 21 | + |
| 22 | + def setUp(self): |
| 23 | + super(TestService, self).setUp() |
| 24 | + |
| 25 | + # Get a shortcut to the ServiceManager Mock |
| 26 | + self.service_mock = self.app.client_manager.compute.services |
| 27 | + self.service_mock.reset_mock() |
| 28 | + |
| 29 | + |
| 30 | +class TestServiceDelete(TestService): |
| 31 | + |
| 32 | + def setUp(self): |
| 33 | + super(TestServiceDelete, self).setUp() |
| 34 | + |
| 35 | + self.service_mock.delete.return_value = None |
| 36 | + |
| 37 | + # Get the command object to test |
| 38 | + self.cmd = service.DeleteService(self.app, None) |
| 39 | + |
| 40 | + def test_service_delete_no_options(self): |
| 41 | + arglist = [ |
| 42 | + compute_fakes.service_id, |
| 43 | + ] |
| 44 | + verifylist = [ |
| 45 | + ('service', compute_fakes.service_id), |
| 46 | + ] |
| 47 | + parsed_args = self.check_parser(self.cmd, arglist, verifylist) |
| 48 | + |
| 49 | + # DisplayCommandBase.take_action() returns two tuples |
| 50 | + self.cmd.take_action(parsed_args) |
| 51 | + |
| 52 | + self.service_mock.delete.assert_called_with( |
| 53 | + compute_fakes.service_id, |
| 54 | + ) |
0 commit comments