def test_list_extensions_json(self): app = v2.APIRouter() ext_midware = extensions.ExtensionMiddleware(app) ser_midware = wsgi.LazySerializationMiddleware(ext_midware) request = webob.Request.blank("/123/extensions") response = request.get_response(ser_midware) self.assertEqual(200, response.status_int) # Make sure we have all the extensions. data = json.loads(response.body) names = [x['name'] for x in data['extensions']] names.sort() self.assertEqual(names, self.ext_list) # Make sure that at least Fox in Sox is correct. (fox_ext, ) = [ x for x in data['extensions'] if x['alias'] == 'FOXNSOX'] self.assertEqual(fox_ext, { 'namespace': 'http://www.fox.in.socks/api/ext/pie/v1.0', 'name': 'Fox In Socks', 'updated': '2011-01-22T13:25:27-06:00', 'description': 'The Fox In Socks Extension', 'alias': 'FOXNSOX', 'links': [] }, )
def setUp(self): super(SchedulerHintsTestCase, self).setUp() self.fake_instance = fakes.stub_instance(1, uuid=UUID) app = compute.APIRouter() app = extensions.ExtensionMiddleware(app) app = wsgi.LazySerializationMiddleware(app) self.app = app
def setUp(self): super(CreateBackupTests, self).setUp() self.stubs.Set(compute.API, 'get', fake_compute_api_get) self.backup_stubs = fakes.stub_out_compute_api_backup(self.stubs) router = compute_api.APIRouter() ext_middleware = extensions.ExtensionMiddleware(router) self.app = wsgi.LazySerializationMiddleware(ext_middleware) self.uuid = utils.gen_uuid()
def setUp(self): super(ServerActionsTest, self).setUp() self.flags(allow_admin_api=True) self.flags(verbose=True) self.stubs.Set(nova.compute.API, 'get_actions', fake_get_actions) self.stubs.Set(nova.compute.API, 'get', fake_instance_get) self.compute_api = nova.compute.API() self.router = compute.APIRouter() ext_middleware = extensions.ExtensionMiddleware(self.router) self.app = wsgi.LazySerializationMiddleware(ext_middleware)
def test_get_resources_with_stub_mgr(self): def _req_handler(req, res, body): # only handle JSON responses body['flavor']['googoose'] = req.GET.get('chewing') return res req_ext = extensions.RequestExtension('GET', '/v2/123/flavors/:(id)', _req_handler) manager = StubExtensionManager(None, None, req_ext) app = fakes.wsgi_app(serialization=base_wsgi.Middleware) ext_midware = extensions.ExtensionMiddleware(app, manager) ser_midware = wsgi.LazySerializationMiddleware(ext_midware) request = webob.Request.blank("/v2/123/flavors/1?chewing=bluegoo") request.environ['api.version'] = '2' response = request.get_response(ser_midware) self.assertEqual(200, response.status_int) response_data = json.loads(response.body) self.assertEqual('bluegoo', response_data['flavor']['googoose'])
def setUp(self): """Run before each test.""" BaseLimitTestSuite.setUp(self) self.controller = wsgi.LazySerializationMiddleware( limits.create_resource()) self.maxDiff = None