def test_versions_index(self): req = fakes.HTTPRequest.blank('/') req.method = 'GET' req.content_type = 'application/json' resource = versions.Versions() result = resource.dispatch(resource.index, req, {}) ids = [v['id'] for v in result['versions']] self.assertEqual(set(['v1.0', 'v1.0']), set(ids))
def test_versions_index_disable_v1(self): self.flags(enable_v1_api=False) req = fakes.HTTPRequest.blank('/') req.method = 'GET' req.content_type = 'application/json' resource = versions.Versions() result = resource.dispatch(resource.index, req, {}) ids = [v['id'] for v in result['versions']] self.assertEqual(set([]), set(ids))
def test_get_version_list(self): req = webob.Request.blank('/', base_url='http://127.0.0.1:8760/') req.accept = 'application/json' res = versions.Versions().index(req) results = res['versions'] expected = [ { 'id': 'v1.0', 'status': 'SUPPORTED', 'updated': '2014-06-28T12:20:21Z', 'links': [{'rel': 'self', 'href': 'http://127.0.0.1:8760/v1/'}], }, ] self.assertEqual(expected, results)
def wsgi_app(inner_app_v1=None, fake_auth=True, fake_auth_context=None, use_no_auth=False, ext_mgr=None): if fake_auth: if fake_auth_context is not None: ctxt = fake_auth_context else: ctxt = context.RequestContext('fake', 'fake', auth_token=True) api_v1 = fault.FaultWrapper(auth.InjectContext(ctxt, inner_app_v1)) mapper = urlmap.URLMap() mapper['/v1'] = api_v1 mapper['/'] = fault.FaultWrapper(versions.Versions()) return mapper
def test_versions_action_args_multi(self): request_environment = {'PATH_INFO': '/fake/path'} resource = versions.Versions() result = resource.get_action_args(request_environment) self.assertEqual('multi', result['action'])
def test_versions_action_args_index(self): request_environment = {'PATH_INFO': '/'} resource = versions.Versions() result = resource.get_action_args(request_environment) self.assertEqual('index', result['action'])