Make sure detail view works for volume snaphots
* adds tests for volume router * test uncovered bug in versions that now fixed * fixes bug 940616 Change-Id: I3f780d59d2fd60ebca3d142277a747400fe35336
This commit is contained in:

committed by
Brian Waldon

parent
e2be2d8238
commit
f96dcc39c7
@@ -58,4 +58,5 @@ class APIRouter(nova.api.openstack.APIRouter):
|
||||
|
||||
self.resources['snapshots'] = snapshots.create_resource()
|
||||
mapper.resource("snapshot", "snapshots",
|
||||
controller=self.resources['snapshots'])
|
||||
controller=self.resources['snapshots'],
|
||||
collection={'detail': 'GET'})
|
||||
|
@@ -22,8 +22,8 @@ from nova.api.openstack import wsgi
|
||||
|
||||
|
||||
VERSIONS = {
|
||||
"v1": {
|
||||
"id": "v1",
|
||||
"v1.0": {
|
||||
"id": "v1.0",
|
||||
"status": "CURRENT",
|
||||
"updated": "2012-01-04T11:33:21Z",
|
||||
"links": [
|
||||
@@ -72,7 +72,7 @@ class VolumeVersionV1(object):
|
||||
atom=versions.VersionAtomSerializer)
|
||||
def show(self, req):
|
||||
builder = views_versions.get_view_builder(req)
|
||||
return builder.build_version(VERSIONS['v2.0'])
|
||||
return builder.build_version(VERSIONS['v1.0'])
|
||||
|
||||
|
||||
def create_resource():
|
||||
|
96
nova/tests/api/openstack/volume/test_router.py
Normal file
96
nova/tests/api/openstack/volume/test_router.py
Normal file
@@ -0,0 +1,96 @@
|
||||
# Copyright 2011 Denali Systems, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
|
||||
from nova.api.openstack import volume
|
||||
from nova.api.openstack.volume import snapshots
|
||||
from nova.api.openstack.volume import volumes
|
||||
from nova.api.openstack import wsgi
|
||||
from nova import flags
|
||||
from nova import log as logging
|
||||
from nova import test
|
||||
from nova.tests.api.openstack import fakes
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class FakeController(object):
|
||||
def index(self, req):
|
||||
return {}
|
||||
|
||||
def detail(self, req):
|
||||
return {}
|
||||
|
||||
|
||||
def create_resource():
|
||||
return wsgi.Resource(FakeController())
|
||||
|
||||
|
||||
class VolumeRouterTestCase(test.TestCase):
|
||||
def setUp(self):
|
||||
super(VolumeRouterTestCase, self).setUp()
|
||||
# NOTE(vish): versions is just returning text so, no need to stub.
|
||||
self.stubs.Set(snapshots, 'create_resource', create_resource)
|
||||
self.stubs.Set(volumes, 'create_resource', create_resource)
|
||||
self.app = volume.APIRouter()
|
||||
|
||||
def test_versions(self):
|
||||
req = fakes.HTTPRequest.blank('')
|
||||
req.method = 'GET'
|
||||
req.content_type = 'application/json'
|
||||
response = req.get_response(self.app)
|
||||
self.assertEqual(302, response.status_int)
|
||||
req = fakes.HTTPRequest.blank('/')
|
||||
req.method = 'GET'
|
||||
req.content_type = 'application/json'
|
||||
response = req.get_response(self.app)
|
||||
self.assertEqual(200, response.status_int)
|
||||
|
||||
def test_volumes(self):
|
||||
req = fakes.HTTPRequest.blank('/fake/volumes')
|
||||
req.method = 'GET'
|
||||
req.content_type = 'application/json'
|
||||
response = req.get_response(self.app)
|
||||
self.assertEqual(200, response.status_int)
|
||||
|
||||
def test_volumes_detail(self):
|
||||
req = fakes.HTTPRequest.blank('/fake/volumes/detail')
|
||||
req.method = 'GET'
|
||||
req.content_type = 'application/json'
|
||||
response = req.get_response(self.app)
|
||||
self.assertEqual(200, response.status_int)
|
||||
|
||||
def test_types(self):
|
||||
req = fakes.HTTPRequest.blank('/fake/types')
|
||||
req.method = 'GET'
|
||||
req.content_type = 'application/json'
|
||||
response = req.get_response(self.app)
|
||||
self.assertEqual(200, response.status_int)
|
||||
|
||||
def test_snapshots(self):
|
||||
req = fakes.HTTPRequest.blank('/fake/snapshots')
|
||||
req.method = 'GET'
|
||||
req.content_type = 'application/json'
|
||||
response = req.get_response(self.app)
|
||||
self.assertEqual(200, response.status_int)
|
||||
|
||||
def test_snapshots_detail(self):
|
||||
req = fakes.HTTPRequest.blank('/fake/snapshots/detail')
|
||||
req.method = 'GET'
|
||||
req.content_type = 'application/json'
|
||||
response = req.get_response(self.app)
|
||||
self.assertEqual(200, response.status_int)
|
@@ -18,6 +18,7 @@ import datetime
|
||||
from lxml import etree
|
||||
import webob
|
||||
|
||||
from nova.api.openstack import volume as openstack_volume
|
||||
from nova.api.openstack.volume import snapshots
|
||||
from nova import exception
|
||||
from nova import flags
|
||||
|
Reference in New Issue
Block a user