Debian Codegraph @

ironic_tempest_plugin/tests/api/admin/test_api_discovery.py

raw
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 tempest.lib import decorators
14
15 from ironic_tempest_plugin.tests.api.admin import api_microversion_fixture
16 from ironic_tempest_plugin.tests.api import base
17
18
19 class TestApiDiscovery(base.BaseBaremetalTest):
20 """Tests for API discovery features."""
21
22 @decorators.idempotent_id('a3c27e94-f56c-42c4-8600-d6790650b9c5')
23 def test_api_versions(self):
24 self.useFixture(
25 api_microversion_fixture.APIMicroversionFixture(None))
26 _, descr = self.client.get_api_description()
27 expected_versions = ('v1',)
28 versions = [version['id'] for version in descr['versions']]
29
30 for v in expected_versions:
31 self.assertIn(v, versions)
32
33 @decorators.idempotent_id('896283a6-488e-4f31-af78-6614286cbe0d')
34 def test_default_version(self):
35 self.useFixture(
36 api_microversion_fixture.APIMicroversionFixture(None))
37 _, descr = self.client.get_api_description()
38 default_version = descr['default_version']
39 self.assertEqual('v1', default_version['id'])
40
41 @decorators.idempotent_id('abc0b34d-e684-4546-9728-ab7a9ad9f174')
42 def test_version_1_resources(self):
43 _, descr = self.client.get_version_description(version='v1')
44 expected_resources = ('nodes', 'chassis',
45 'ports', 'links', 'media_types')
46
47 for res in expected_resources:
48 self.assertIn(res, descr)