本文整理匯總了Python中pecan.testing方法的典型用法代碼示例。如果您正苦於以下問題:Python pecan.testing方法的具體用法?Python pecan.testing怎麽用?Python pecan.testing使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pecan
的用法示例。
在下文中一共展示了pecan.testing方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _make_app
# 需要導入模塊: import pecan [as 別名]
# 或者: from pecan import testing [as 別名]
def _make_app(self, enable_acl=False):
# Determine where we are so we can set up paths in the config
root_dir = self.get_path()
self.config = {
'app': {
'root': 'watcher.api.controllers.root.RootController',
'modules': ['watcher.api'],
'hooks': [
hooks.ContextHook(),
hooks.NoExceptionTracebackHook()
],
'template_path': '%s/api/templates' % root_dir,
'enable_acl': enable_acl,
'acl_public_routes': ['/', '/v1'],
},
}
return pecan.testing.load_test_app(self.config)
示例2: _make_app
# 需要導入模塊: import pecan [as 別名]
# 或者: from pecan import testing [as 別名]
def _make_app(self, config=None):
if not config:
config = self.config
return pecan.testing.load_test_app(config)
示例3: _make_app
# 需要導入模塊: import pecan [as 別名]
# 或者: from pecan import testing [as 別名]
def _make_app(self):
# Note: we need to set argv=() to stop the wsgi setup_app from
# pulling in the testing tool sys.argv
return pecan.testing.load_test_app({'app': pconfig.app,
'wsme': pconfig.wsme}, argv=())
示例4: _get_versions_with_config
# 需要導入模塊: import pecan [as 別名]
# 或者: from pecan import testing [as 別名]
def _get_versions_with_config(self):
# Note: we need to set argv=() to stop the wsgi setup_app from
# pulling in the testing tool sys.argv
app = pecan.testing.load_test_app({'app': pconfig.app,
'wsme': pconfig.wsme}, argv=())
return self.get(app=app, path='/').json.get('versions', None)
示例5: _make_app
# 需要導入模塊: import pecan [as 別名]
# 或者: from pecan import testing [as 別名]
def _make_app(self):
# Determine where we are so we can set up paths in the config
root_dir = self.get_path()
self.app_config = {
'app': {
'root': 'cyborg.api.controllers.root.RootController',
'modules': ['cyborg.api'],
'static_root': '%s/public' % root_dir,
'template_path': '%s/api/templates' % root_dir,
'acl_public_routes': ['/', '/v1/.*'],
},
}
return pecan.testing.load_test_app(self.app_config)
示例6: setUp
# 需要導入模塊: import pecan [as 別名]
# 或者: from pecan import testing [as 別名]
def setUp(self):
super(APITest, self).setUp()
# Config package directory before app starts.
package_dir = tempfile.mkdtemp(prefix='tmp_qinling')
self.override_config('file_system_dir', package_dir, 'storage')
self.addCleanup(shutil.rmtree, package_dir, True)
# Disable authentication by default for API tests.
self.override_config('auth_enable', False, group='pecan')
# Disable job handler. The following pecan app instantiation will
# invoke qinling.api.app:setup_app()
self.override_config('enable_job_handler', False, group='api')
pecan_opts = CONF.pecan
self.app = pecan.testing.load_test_app({
'app': {
'root': pecan_opts.root,
'modules': pecan_opts.modules,
'debug': pecan_opts.debug,
'auth_enable': False,
}
})
self.addCleanup(pecan.set_config, {}, overwrite=True)
self.patch_ctx = mock.patch('qinling.context.Context.from_environ')
self.mock_ctx = self.patch_ctx.start()
self.mock_ctx.return_value = self.ctx
self.addCleanup(self.patch_ctx.stop)