From acc2d106abfb4fed0ff5d0d0c246d69f9ea1758b Mon Sep 17 00:00:00 2001 From: Ankur Gupta Date: Fri, 24 Mar 2017 12:39:22 -0500 Subject: Refactor Extension show and list command 1.keep the column display order consist in extension list with and without "--long" option. 2.rework for network extentsion list, openstacksdk return object, so the logic should be same with other service. 3.add some unit test cases, like: extension list --network --long, extension list --network --compute, to cover regular use cases. 4.raise exact exception when network extension don't exist, avoid internal TypeError in "extension show" commands. Change-Id: I2e23ced80d8da8aa1106b22472db850367b351ce Closes-Bug: #1689233 --- .../tests/functional/common/test_extension.py | 31 ++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'openstackclient/tests/functional') diff --git a/openstackclient/tests/functional/common/test_extension.py b/openstackclient/tests/functional/common/test_extension.py index cc4cb7e1..d7dc398b 100644 --- a/openstackclient/tests/functional/common/test_extension.py +++ b/openstackclient/tests/functional/common/test_extension.py @@ -15,6 +15,8 @@ import json +from tempest.lib import exceptions as tempest_exc + from openstackclient.tests.functional import base @@ -23,7 +25,6 @@ class ExtensionTests(base.TestCase): @classmethod def setUpClass(cls): - # super(NetworkTests, cls).setUp() cls.haz_network = base.is_service_enabled('network') def test_extension_list_compute(self): @@ -38,6 +39,18 @@ class ExtensionTests(base.TestCase): name_list, ) + def test_extension_list_volume(self): + """Test volume extension list""" + json_output = json.loads(self.openstack( + 'extension list -f json ' + + '--volume' + )) + name_list = [item.get('Name') for item in json_output] + self.assertIn( + 'TypesManage', + name_list, + ) + def test_extension_list_network(self): """Test network extension list""" if not self.haz_network: @@ -79,5 +92,19 @@ class ExtensionTests(base.TestCase): )) self.assertEqual( name, - json_output.get('Alias'), + json_output.get('alias'), ) + + def test_extension_show_not_exist(self): + """Test extension show with not existed name""" + if not self.haz_network: + self.skipTest("No Network service present") + + name = 'not_existed_ext' + try: + self.openstack('extension show ' + name) + except tempest_exc.CommandFailed as e: + self.assertIn('ResourceNotFound', str(e)) + self.assertIn(name, str(e)) + else: + self.fail('CommandFailed should be raised') -- cgit v1.2.1