|
18 | 18 | from openstackclient.tests.functional import base |
19 | 19 |
|
20 | 20 |
|
21 | | -class TestExtension(base.TestCase): |
22 | | - """Functional tests for extension.""" |
| 21 | +class ExtensionTests(base.TestCase): |
| 22 | + """Functional tests for extension""" |
23 | 23 |
|
24 | | - def test_extension_list(self): |
25 | | - """Test extension list.""" |
| 24 | + @classmethod |
| 25 | + def setUpClass(cls): |
| 26 | + # super(NetworkTests, cls).setUp() |
| 27 | + cls.haz_network = base.is_service_enabled('network') |
| 28 | + |
| 29 | + def test_extension_list_compute(self): |
| 30 | + """Test compute extension list""" |
26 | 31 | json_output = json.loads(self.openstack( |
27 | | - 'extension list -f json ' + '--network') |
| 32 | + 'extension list -f json ' + |
| 33 | + '--compute' |
| 34 | + )) |
| 35 | + name_list = [item.get('Name') for item in json_output] |
| 36 | + self.assertIn( |
| 37 | + 'ImageSize', |
| 38 | + name_list, |
28 | 39 | ) |
29 | | - self.assertEqual( |
| 40 | + |
| 41 | + def test_extension_list_network(self): |
| 42 | + """Test network extension list""" |
| 43 | + if not self.haz_network: |
| 44 | + self.skipTest("No Network service present") |
| 45 | + |
| 46 | + json_output = json.loads(self.openstack( |
| 47 | + 'extension list -f json ' + |
| 48 | + '--network' |
| 49 | + )) |
| 50 | + name_list = [item.get('Name') for item in json_output] |
| 51 | + self.assertIn( |
30 | 52 | 'Default Subnetpools', |
31 | | - json_output[0]['Name'], |
| 53 | + name_list, |
32 | 54 | ) |
33 | 55 |
|
34 | | - def test_extension_show(self): |
35 | | - """Test extension show.""" |
| 56 | + # NOTE(dtroyer): Only network extensions are currently supported but |
| 57 | + # I am going to leave this here anyway as a reminder |
| 58 | + # fix that. |
| 59 | + # def test_extension_show_compute(self): |
| 60 | + # """Test compute extension show""" |
| 61 | + # json_output = json.loads(self.openstack( |
| 62 | + # 'extension show -f json ' + |
| 63 | + # 'ImageSize' |
| 64 | + # )) |
| 65 | + # self.assertEqual( |
| 66 | + # 'OS-EXT-IMG-SIZE', |
| 67 | + # json_output.get('Alias'), |
| 68 | + # ) |
| 69 | + |
| 70 | + def test_extension_show_network(self): |
| 71 | + """Test network extension show""" |
| 72 | + if not self.haz_network: |
| 73 | + self.skipTest("No Network service present") |
| 74 | + |
36 | 75 | name = 'agent' |
37 | 76 | json_output = json.loads(self.openstack( |
38 | | - 'extension show -f json ' + name) |
39 | | - ) |
| 77 | + 'extension show -f json ' + |
| 78 | + name |
| 79 | + )) |
40 | 80 | self.assertEqual( |
41 | 81 | name, |
42 | | - json_output.get('Alias')) |
| 82 | + json_output.get('Alias'), |
| 83 | + ) |
0 commit comments