|
| 1 | +# Copyright 2023 Red Hat, 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 | +from openstackclient.image.v2 import metadef_properties |
| 16 | +from openstackclient.tests.unit.image.v2 import fakes as image_fakes |
| 17 | + |
| 18 | + |
| 19 | +class TestMetadefPropertyList(image_fakes.TestImagev2): |
| 20 | + _metadef_property = [image_fakes.create_one_metadef_property()] |
| 21 | + |
| 22 | + columns = ['name', 'title', 'type'] |
| 23 | + |
| 24 | + def setUp(self): |
| 25 | + super().setUp() |
| 26 | + |
| 27 | + self.image_client.metadef_properties.side_effect = [ |
| 28 | + self._metadef_property, |
| 29 | + [], |
| 30 | + ] |
| 31 | + |
| 32 | + self.cmd = metadef_properties.ListMetadefProperties(self.app, None) |
| 33 | + self.datalist = self._metadef_property |
| 34 | + |
| 35 | + def test_metadef_property_list(self): |
| 36 | + arglist = ['my-namespace'] |
| 37 | + parsed_args = self.check_parser(self.cmd, arglist, []) |
| 38 | + |
| 39 | + columns, data = self.cmd.take_action(parsed_args) |
| 40 | + |
| 41 | + self.assertEqual(self.columns, columns) |
| 42 | + self.assertEqual(getattr(self.datalist[0], 'name'), next(data)[0]) |
0 commit comments