|
| 1 | +# Copyright 2014 eBay 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.identity.v2_0 import token |
| 17 | +from openstackclient.tests.identity.v2_0 import fakes as identity_fakes |
| 18 | + |
| 19 | + |
| 20 | +class TestToken(identity_fakes.TestIdentityv2): |
| 21 | + |
| 22 | + def setUp(self): |
| 23 | + super(TestToken, self).setUp() |
| 24 | + |
| 25 | + # Get a shortcut to the Service Catalog Mock |
| 26 | + self.sc_mock = self.app.client_manager.identity.service_catalog |
| 27 | + self.sc_mock.reset_mock() |
| 28 | + |
| 29 | + |
| 30 | +class TestTokenCreate(TestToken): |
| 31 | + |
| 32 | + def setUp(self): |
| 33 | + super(TestTokenCreate, self).setUp() |
| 34 | + |
| 35 | + self.sc_mock.get_token.return_value = identity_fakes.TOKEN |
| 36 | + self.cmd = token.CreateToken(self.app, None) |
| 37 | + |
| 38 | + def test_token_create(self): |
| 39 | + arglist = [] |
| 40 | + verifylist = [] |
| 41 | + parsed_args = self.check_parser(self.cmd, arglist, verifylist) |
| 42 | + |
| 43 | + # DisplayCommandBase.take_action() returns two tuples |
| 44 | + columns, data = self.cmd.take_action(parsed_args) |
| 45 | + |
| 46 | + self.sc_mock.get_token.assert_called_with() |
| 47 | + |
| 48 | + collist = ('expires', 'id', 'project_id', 'user_id') |
| 49 | + self.assertEqual(columns, collist) |
| 50 | + datalist = ( |
| 51 | + identity_fakes.token_expires, |
| 52 | + identity_fakes.token_id, |
| 53 | + identity_fakes.project_id, |
| 54 | + identity_fakes.user_id, |
| 55 | + ) |
| 56 | + self.assertEqual(data, datalist) |
0 commit comments