Merge "[placement] Allow both /placement and /placement/ to work"
This commit is contained in:
@@ -48,6 +48,14 @@ ROUTE_DECLARATIONS = {
|
|||||||
'/': {
|
'/': {
|
||||||
'GET': root.home,
|
'GET': root.home,
|
||||||
},
|
},
|
||||||
|
# NOTE(cdent): This allows '/placement/' and '/placement' to
|
||||||
|
# both work as the root of the service, which we probably want
|
||||||
|
# for those situations where the service is mounted under a
|
||||||
|
# prefix (as it is in devstack). While weird, an empty string is
|
||||||
|
# a legit key in a dictionary and matches as desired in Routes.
|
||||||
|
'': {
|
||||||
|
'GET': root.home,
|
||||||
|
},
|
||||||
'/resource_providers': {
|
'/resource_providers': {
|
||||||
'GET': resource_provider.list_resource_providers,
|
'GET': resource_provider.list_resource_providers,
|
||||||
'POST': resource_provider.create_resource_provider
|
'POST': resource_provider.create_resource_provider
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import routes
|
|||||||
import webob
|
import webob
|
||||||
|
|
||||||
from nova.api.openstack.placement import handler
|
from nova.api.openstack.placement import handler
|
||||||
|
from nova.api.openstack.placement.handlers import root
|
||||||
from nova import test
|
from nova import test
|
||||||
from nova.tests import uuidsentinel
|
from nova.tests import uuidsentinel
|
||||||
|
|
||||||
@@ -124,3 +125,20 @@ class PlacementLoggingTest(test.NoDBTestCase):
|
|||||||
app, environ, start_response)
|
app, environ, start_response)
|
||||||
mocked_log.error.assert_not_called()
|
mocked_log.error.assert_not_called()
|
||||||
mocked_log.exception.assert_not_called()
|
mocked_log.exception.assert_not_called()
|
||||||
|
|
||||||
|
|
||||||
|
class DeclarationsTest(test.NoDBTestCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(DeclarationsTest, self).setUp()
|
||||||
|
self.mapper = handler.make_map(handler.ROUTE_DECLARATIONS)
|
||||||
|
|
||||||
|
def test_root_slash_match(self):
|
||||||
|
environ = _environ(path='/')
|
||||||
|
result = self.mapper.match(environ=environ)
|
||||||
|
self.assertEqual(root.home, result['action'])
|
||||||
|
|
||||||
|
def test_root_empty_match(self):
|
||||||
|
environ = _environ(path='')
|
||||||
|
result = self.mapper.match(environ=environ)
|
||||||
|
self.assertEqual(root.home, result['action'])
|
||||||
|
|||||||
Reference in New Issue
Block a user