Ihar Hrachyshka | 34feb5b | 2016-06-14 16:16:06 +0200 | [diff] [blame] | 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 | |
Chandan Kumar | c125fd1 | 2017-11-15 19:41:01 +0530 | [diff] [blame] | 13 | from tempest.common import utils |
Hongbin Lu | 79318ac | 2018-08-07 17:49:49 +0000 | [diff] [blame] | 14 | from tempest import config |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 15 | from tempest.lib import decorators |
Ihar Hrachyshka | 34feb5b | 2016-06-14 16:16:06 +0200 | [diff] [blame] | 16 | |
Chandan Kumar | 667d3d3 | 2017-09-22 12:24:06 +0530 | [diff] [blame] | 17 | from neutron_tempest_plugin.api import base |
Ihar Hrachyshka | 34feb5b | 2016-06-14 16:16:06 +0200 | [diff] [blame] | 18 | |
| 19 | |
Hongbin Lu | 79318ac | 2018-08-07 17:49:49 +0000 | [diff] [blame] | 20 | CONF = config.CONF |
| 21 | |
| 22 | |
Ihar Hrachyshka | 34feb5b | 2016-06-14 16:16:06 +0200 | [diff] [blame] | 23 | class ExtensionsTest(base.BaseNetworkTest): |
| 24 | |
Hongbin Lu | 79318ac | 2018-08-07 17:49:49 +0000 | [diff] [blame] | 25 | def _test_list_extensions_includes(self, exts): |
Ihar Hrachyshka | 34feb5b | 2016-06-14 16:16:06 +0200 | [diff] [blame] | 26 | body = self.client.list_extensions() |
| 27 | extensions = {ext_['alias'] for ext_ in body['extensions']} |
| 28 | self.assertNotEmpty(extensions, "Extension list returned is empty") |
Hongbin Lu | 79318ac | 2018-08-07 17:49:49 +0000 | [diff] [blame] | 29 | for ext in exts: |
| 30 | ext_enabled = utils.is_extension_enabled(ext, "network") |
| 31 | if ext_enabled: |
| 32 | self.assertIn(ext, extensions) |
| 33 | else: |
| 34 | self.assertNotIn(ext, extensions) |
Ihar Hrachyshka | 34feb5b | 2016-06-14 16:16:06 +0200 | [diff] [blame] | 35 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 36 | @decorators.idempotent_id('262420b7-a4bb-4a3e-b4b5-e73bad18df8c') |
Ihar Hrachyshka | 34feb5b | 2016-06-14 16:16:06 +0200 | [diff] [blame] | 37 | def test_list_extensions_sorting(self): |
Hongbin Lu | 79318ac | 2018-08-07 17:49:49 +0000 | [diff] [blame] | 38 | self._test_list_extensions_includes(['sorting']) |
Ihar Hrachyshka | 34feb5b | 2016-06-14 16:16:06 +0200 | [diff] [blame] | 39 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 40 | @decorators.idempotent_id('19db409e-a23f-445d-8bc8-ca3d64c84706') |
Ihar Hrachyshka | 34feb5b | 2016-06-14 16:16:06 +0200 | [diff] [blame] | 41 | def test_list_extensions_pagination(self): |
Hongbin Lu | 79318ac | 2018-08-07 17:49:49 +0000 | [diff] [blame] | 42 | self._test_list_extensions_includes(['pagination']) |
Dariusz Smigiel | f5fb4c6 | 2016-08-19 15:41:17 +0000 | [diff] [blame] | 43 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 44 | @decorators.idempotent_id('155b7bc2-e358-4dd8-bf3e-1774c084567f') |
Dariusz Smigiel | f5fb4c6 | 2016-08-19 15:41:17 +0000 | [diff] [blame] | 45 | def test_list_extensions_project_id(self): |
Hongbin Lu | 79318ac | 2018-08-07 17:49:49 +0000 | [diff] [blame] | 46 | self._test_list_extensions_includes(['project-id']) |
| 47 | |
| 48 | @decorators.idempotent_id('c7597fac-2404-45b1-beb4-523c8b1d4604') |
| 49 | def test_list_extensions_includes_all(self): |
| 50 | extensions = CONF.network_feature_enabled.api_extensions |
| 51 | if not extensions: |
| 52 | raise self.skipException("Extension list is empty") |
| 53 | if extensions[0] == 'all': |
| 54 | raise self.skipException("No lists of enabled extensions provided") |
| 55 | |
| 56 | self._test_list_extensions_includes(extensions) |