|
| 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 | +from openstackclient.network import sdk_utils |
| 14 | +from openstackclient.tests.unit import utils as tests_utils |
| 15 | + |
| 16 | + |
| 17 | +class TestSDKUtils(tests_utils.TestCase): |
| 18 | + |
| 19 | + def setUp(self): |
| 20 | + super(TestSDKUtils, self).setUp() |
| 21 | + |
| 22 | + def _test_get_osc_show_columns_for_sdk_resource( |
| 23 | + self, sdk_resource, column_map, |
| 24 | + expected_display_columns, expected_attr_columns): |
| 25 | + display_columns, attr_columns = \ |
| 26 | + sdk_utils.get_osc_show_columns_for_sdk_resource( |
| 27 | + sdk_resource, column_map) |
| 28 | + self.assertEqual(expected_display_columns, display_columns) |
| 29 | + self.assertEqual(expected_attr_columns, attr_columns) |
| 30 | + |
| 31 | + def test_get_osc_show_columns_for_sdk_resource_empty(self): |
| 32 | + self._test_get_osc_show_columns_for_sdk_resource( |
| 33 | + {}, {}, tuple(), tuple()) |
| 34 | + |
| 35 | + def test_get_osc_show_columns_for_sdk_resource_empty_map(self): |
| 36 | + self._test_get_osc_show_columns_for_sdk_resource( |
| 37 | + {'foo': 'foo1'}, {}, |
| 38 | + ('foo',), ('foo',)) |
| 39 | + |
| 40 | + def test_get_osc_show_columns_for_sdk_resource_empty_data(self): |
| 41 | + self._test_get_osc_show_columns_for_sdk_resource( |
| 42 | + {}, {'foo': 'foo_map'}, |
| 43 | + ('foo_map',), ('foo_map',)) |
| 44 | + |
| 45 | + def test_get_osc_show_columns_for_sdk_resource_map(self): |
| 46 | + self._test_get_osc_show_columns_for_sdk_resource( |
| 47 | + {'foo': 'foo1'}, {'foo': 'foo_map'}, |
| 48 | + ('foo_map',), ('foo',)) |
| 49 | + |
| 50 | + def test_get_osc_show_columns_for_sdk_resource_map_dup(self): |
| 51 | + self._test_get_osc_show_columns_for_sdk_resource( |
| 52 | + {'foo': 'foo1', 'foo_map': 'foo1'}, {'foo': 'foo_map'}, |
| 53 | + ('foo_map',), ('foo',)) |
| 54 | + |
| 55 | + def test_get_osc_show_columns_for_sdk_resource_map_full(self): |
| 56 | + self._test_get_osc_show_columns_for_sdk_resource( |
| 57 | + {'foo': 'foo1', 'bar': 'bar1'}, |
| 58 | + {'foo': 'foo_map', 'new': 'bar'}, |
| 59 | + ('bar', 'foo_map'), ('bar', 'foo')) |
0 commit comments