diff options
Diffstat (limited to 'ironic/tests/unit/api/controllers/v1/test_root.py')
-rw-r--r-- | ironic/tests/unit/api/controllers/v1/test_root.py | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/ironic/tests/unit/api/controllers/v1/test_root.py b/ironic/tests/unit/api/controllers/v1/test_root.py index b3e58b817..78d3053e4 100644 --- a/ironic/tests/unit/api/controllers/v1/test_root.py +++ b/ironic/tests/unit/api/controllers/v1/test_root.py @@ -17,6 +17,7 @@ from unittest import mock from webob import exc as webob_exc from ironic.api.controllers import v1 as v1_api +from ironic.api.controllers.v1 import versions from ironic.tests import base as test_base from ironic.tests.unit.api import base as api_base @@ -28,6 +29,130 @@ class TestV1Routing(api_base.BaseApiTest): mock.ANY, mock.ANY) + def test_min_version(self): + response = self.get_json( + '/', + headers={ + 'Accept': 'application/json', + 'X-OpenStack-Ironic-API-Version': + versions.min_version_string() + }) + self.assertEqual({ + 'id': 'v1', + 'links': [ + {'href': 'http://localhost/v1/', 'rel': 'self'}, + {'href': 'https://docs.openstack.org//ironic/latest' + '/contributor//webapi.html', + 'rel': 'describedby', 'type': 'text/html'} + ], + 'media_types': { + 'base': 'application/json', + 'type': 'application/vnd.openstack.ironic.v1+json' + }, + 'version': { + 'id': 'v1', + 'links': [{'href': 'http://localhost/v1/', 'rel': 'self'}], + 'status': 'CURRENT', + 'min_version': versions.min_version_string(), + 'version': versions.max_version_string() + }, + 'chassis': [ + {'href': 'http://localhost/v1/chassis/', 'rel': 'self'}, + {'href': 'http://localhost/chassis/', 'rel': 'bookmark'} + ], + 'nodes': [ + {'href': 'http://localhost/v1/nodes/', 'rel': 'self'}, + {'href': 'http://localhost/nodes/', 'rel': 'bookmark'} + ], + 'ports': [ + {'href': 'http://localhost/v1/ports/', 'rel': 'self'}, + {'href': 'http://localhost/ports/', 'rel': 'bookmark'} + ], + 'drivers': [ + {'href': 'http://localhost/v1/drivers/', 'rel': 'self'}, + {'href': 'http://localhost/drivers/', 'rel': 'bookmark'} + ], + }, response) + + def test_max_version(self): + response = self.get_json( + '/', + headers={ + 'Accept': 'application/json', + 'X-OpenStack-Ironic-API-Version': + versions.max_version_string() + }) + self.assertEqual({ + 'id': 'v1', + 'links': [ + {'href': 'http://localhost/v1/', 'rel': 'self'}, + {'href': 'https://docs.openstack.org//ironic/latest' + '/contributor//webapi.html', + 'rel': 'describedby', 'type': 'text/html'} + ], + 'media_types': { + 'base': 'application/json', + 'type': 'application/vnd.openstack.ironic.v1+json' + }, + 'version': { + 'id': 'v1', + 'links': [{'href': 'http://localhost/v1/', 'rel': 'self'}], + 'status': 'CURRENT', + 'min_version': versions.min_version_string(), + 'version': versions.max_version_string() + }, + 'allocations': [ + {'href': 'http://localhost/v1/allocations/', 'rel': 'self'}, + {'href': 'http://localhost/allocations/', 'rel': 'bookmark'} + ], + 'chassis': [ + {'href': 'http://localhost/v1/chassis/', 'rel': 'self'}, + {'href': 'http://localhost/chassis/', 'rel': 'bookmark'} + ], + 'conductors': [ + {'href': 'http://localhost/v1/conductors/', 'rel': 'self'}, + {'href': 'http://localhost/conductors/', 'rel': 'bookmark'} + ], + 'deploy_templates': [ + {'href': 'http://localhost/v1/deploy_templates/', + 'rel': 'self'}, + {'href': 'http://localhost/deploy_templates/', + 'rel': 'bookmark'} + ], + 'drivers': [ + {'href': 'http://localhost/v1/drivers/', 'rel': 'self'}, + {'href': 'http://localhost/drivers/', 'rel': 'bookmark'} + ], + 'events': [ + {'href': 'http://localhost/v1/events/', 'rel': 'self'}, + {'href': 'http://localhost/events/', 'rel': 'bookmark'} + ], + 'heartbeat': [ + {'href': 'http://localhost/v1/heartbeat/', 'rel': 'self'}, + {'href': 'http://localhost/heartbeat/', 'rel': 'bookmark'} + ], + 'lookup': [ + {'href': 'http://localhost/v1/lookup/', 'rel': 'self'}, + {'href': 'http://localhost/lookup/', 'rel': 'bookmark'} + ], + 'nodes': [ + {'href': 'http://localhost/v1/nodes/', 'rel': 'self'}, + {'href': 'http://localhost/nodes/', 'rel': 'bookmark'} + ], + 'portgroups': [ + {'href': 'http://localhost/v1/portgroups/', 'rel': 'self'}, + {'href': 'http://localhost/portgroups/', 'rel': 'bookmark'} + ], + 'ports': [ + {'href': 'http://localhost/v1/ports/', 'rel': 'self'}, + {'href': 'http://localhost/ports/', 'rel': 'bookmark'} + ], + 'volume': [ + {'href': 'http://localhost/v1/volume/', 'rel': 'self'}, + {'href': 'http://localhost/volume/', 'rel': 'bookmark'} + ] + }, response) + class TestCheckVersions(test_base.TestCase): |