Updates for version list to show correct references
Updated views to consider version while creating href. Updated fakes to consider version while creating fake href. Updated some test cases in v2 api which were using v1 as expected output Change-Id: Ib05180041309ef75c3718924969bd2354d6d8b3a Closes-Bug: #1261849
This commit is contained in:
parent
5be4620ae5
commit
edc93383f7
@ -38,7 +38,8 @@ class ViewBuilder(object):
|
||||
"id": version['id'],
|
||||
"status": version['status'],
|
||||
"links": [{"rel": "self",
|
||||
"href": self.generate_href(req.path), }, ],
|
||||
"href": self.generate_href(version['id'],
|
||||
req.path), }, ],
|
||||
"media-types": version['media-types'], })
|
||||
|
||||
return dict(choices=version_objs)
|
||||
@ -64,16 +65,20 @@ class ViewBuilder(object):
|
||||
|
||||
def _build_links(self, version_data):
|
||||
"""Generate a container of links that refer to the provided version."""
|
||||
href = self.generate_href()
|
||||
href = self.generate_href(version_data['id'])
|
||||
|
||||
links = [{'rel': 'self',
|
||||
'href': href, }, ]
|
||||
|
||||
return links
|
||||
|
||||
def generate_href(self, path=None):
|
||||
def generate_href(self, version, path=None):
|
||||
"""Create an url that refers to a specific version_number."""
|
||||
if version.find('v1.') == 0:
|
||||
version_number = 'v1'
|
||||
else:
|
||||
version_number = 'v2'
|
||||
|
||||
if path:
|
||||
path = path.strip('/')
|
||||
return os.path.join(self.base_url, version_number, path)
|
||||
|
@ -133,7 +133,12 @@ class HTTPRequest(webob.Request):
|
||||
|
||||
@classmethod
|
||||
def blank(cls, *args, **kwargs):
|
||||
if args != None:
|
||||
if args[0].find('v1') == 0:
|
||||
kwargs['base_url'] = 'http://localhost/v1'
|
||||
else:
|
||||
kwargs['base_url'] = 'http://localhost/v2'
|
||||
|
||||
use_admin_context = kwargs.pop('use_admin_context', False)
|
||||
out = os_wsgi.Request.blank(*args, **kwargs)
|
||||
out.environ['cinder.context'] = FakeRequestContext(
|
||||
|
@ -94,7 +94,7 @@ class VolumeApiTest(test.TestCase):
|
||||
'description': 'Volume Test Desc',
|
||||
'id': '1',
|
||||
'links':
|
||||
[{'href': 'http://localhost/v1/fake/volumes/1',
|
||||
[{'href': 'http://localhost/v2/fake/volumes/1',
|
||||
'rel': 'self'},
|
||||
{'href': 'http://localhost/fake/volumes/1',
|
||||
'rel': 'bookmark'}],
|
||||
@ -196,7 +196,7 @@ class VolumeApiTest(test.TestCase):
|
||||
'description': 'Volume Test Desc',
|
||||
'id': '1',
|
||||
'links':
|
||||
[{'href': 'http://localhost/v1/fake/volumes/1',
|
||||
[{'href': 'http://localhost/v2/fake/volumes/1',
|
||||
'rel': 'self'},
|
||||
{'href': 'http://localhost/fake/volumes/1',
|
||||
'rel': 'bookmark'}],
|
||||
@ -284,7 +284,7 @@ class VolumeApiTest(test.TestCase):
|
||||
'size': 1,
|
||||
'links': [
|
||||
{
|
||||
'href': 'http://localhost/v1/fake/volumes/1',
|
||||
'href': 'http://localhost/v2/fake/volumes/1',
|
||||
'rel': 'self'
|
||||
},
|
||||
{
|
||||
@ -331,7 +331,7 @@ class VolumeApiTest(test.TestCase):
|
||||
'size': 1,
|
||||
'links': [
|
||||
{
|
||||
'href': 'http://localhost/v1/fake/volumes/1',
|
||||
'href': 'http://localhost/v2/fake/volumes/1',
|
||||
'rel': 'self'
|
||||
},
|
||||
{
|
||||
@ -388,7 +388,7 @@ class VolumeApiTest(test.TestCase):
|
||||
'size': 1,
|
||||
'links': [
|
||||
{
|
||||
'href': 'http://localhost/v1/fake/volumes/1',
|
||||
'href': 'http://localhost/v2/fake/volumes/1',
|
||||
'rel': 'self'
|
||||
},
|
||||
{
|
||||
@ -440,7 +440,7 @@ class VolumeApiTest(test.TestCase):
|
||||
'id': '1',
|
||||
'links': [
|
||||
{
|
||||
'href': 'http://localhost/v1/fake/volumes/1',
|
||||
'href': 'http://localhost/v2/fake/volumes/1',
|
||||
'rel': 'self'
|
||||
},
|
||||
{
|
||||
@ -489,7 +489,7 @@ class VolumeApiTest(test.TestCase):
|
||||
'size': 1,
|
||||
'links': [
|
||||
{
|
||||
'href': 'http://localhost/v1/fake/volumes/1',
|
||||
'href': 'http://localhost/v2/fake/volumes/1',
|
||||
'rel': 'self'
|
||||
},
|
||||
{
|
||||
@ -547,7 +547,7 @@ class VolumeApiTest(test.TestCase):
|
||||
'size': 1,
|
||||
'links': [
|
||||
{
|
||||
'href': 'http://localhost/v1/fakeproject'
|
||||
'href': 'http://localhost/v2/fakeproject'
|
||||
'/volumes/1',
|
||||
'rel': 'self'
|
||||
},
|
||||
@ -879,7 +879,7 @@ class VolumeApiTest(test.TestCase):
|
||||
'size': 1,
|
||||
'links': [
|
||||
{
|
||||
'href': 'http://localhost/v1/fake/volumes/1',
|
||||
'href': 'http://localhost/v2/fake/volumes/1',
|
||||
'rel': 'self'
|
||||
},
|
||||
{
|
||||
@ -919,7 +919,7 @@ class VolumeApiTest(test.TestCase):
|
||||
'size': 1,
|
||||
'links': [
|
||||
{
|
||||
'href': 'http://localhost/v1/fake/volumes/1',
|
||||
'href': 'http://localhost/v2/fake/volumes/1',
|
||||
'rel': 'self'
|
||||
},
|
||||
{
|
||||
@ -984,7 +984,7 @@ class VolumeApiTest(test.TestCase):
|
||||
'size': 1,
|
||||
'links': [
|
||||
{
|
||||
'href': 'http://localhost/v1/fakeproject/volumes/1',
|
||||
'href': 'http://localhost/v2/fakeproject/volumes/1',
|
||||
'rel': 'self'
|
||||
},
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user