|
| 1 | +# Copyright (c) 2016, Intel Corporation. |
| 2 | +# All Rights Reserved. |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 5 | +# not use this file except in compliance with the License. You may obtain |
| 6 | +# a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 | +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | +# License for the specific language governing permissions and limitations |
| 14 | +# under the License. |
| 15 | + |
| 16 | +import mock |
| 17 | + |
| 18 | +from openstackclient.network.v2 import network_qos_rule_type as _qos_rule_type |
| 19 | +from openstackclient.tests.unit.network.v2 import fakes as network_fakes |
| 20 | + |
| 21 | + |
| 22 | +class TestNetworkQosRuleType(network_fakes.TestNetworkV2): |
| 23 | + |
| 24 | + def setUp(self): |
| 25 | + super(TestNetworkQosRuleType, self).setUp() |
| 26 | + # Get a shortcut to the network client |
| 27 | + self.network = self.app.client_manager.network |
| 28 | + |
| 29 | + |
| 30 | +class TestListNetworkQosRuleType(TestNetworkQosRuleType): |
| 31 | + |
| 32 | + # The QoS policies to list up. |
| 33 | + qos_rule_types = ( |
| 34 | + network_fakes.FakeNetworkQosRuleType.create_qos_rule_types(count=3)) |
| 35 | + columns = ( |
| 36 | + 'Type', |
| 37 | + ) |
| 38 | + data = [] |
| 39 | + for qos_rule_type in qos_rule_types: |
| 40 | + data.append(( |
| 41 | + qos_rule_type.type, |
| 42 | + )) |
| 43 | + |
| 44 | + def setUp(self): |
| 45 | + super(TestListNetworkQosRuleType, self).setUp() |
| 46 | + self.network.qos_rule_types = mock.Mock( |
| 47 | + return_value=self.qos_rule_types) |
| 48 | + |
| 49 | + # Get the command object to test |
| 50 | + self.cmd = _qos_rule_type.ListNetworkQosRuleType(self.app, |
| 51 | + self.namespace) |
| 52 | + |
| 53 | + def test_qos_rule_type_list(self): |
| 54 | + arglist = [] |
| 55 | + verifylist = [] |
| 56 | + |
| 57 | + parsed_args = self.check_parser(self.cmd, arglist, verifylist) |
| 58 | + columns, data = self.cmd.take_action(parsed_args) |
| 59 | + |
| 60 | + self.network.qos_rule_types.assert_called_once_with(**{}) |
| 61 | + self.assertEqual(self.columns, columns) |
| 62 | + self.assertEqual(self.data, list(data)) |
0 commit comments