本文整理汇总了Python中pyramid.testing.DummyRequest.request_iface方法的典型用法代码示例。如果您正苦于以下问题:Python DummyRequest.request_iface方法的具体用法?Python DummyRequest.request_iface怎么用?Python DummyRequest.request_iface使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid.testing.DummyRequest
的用法示例。
在下文中一共展示了DummyRequest.request_iface方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_apps_app_view
# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import request_iface [as 别名]
def test_apps_app_view(self):
from ptahcms.manage.apps import ApplicationsModule
factory1 = cms.ApplicationFactory(
TestApp1, '/test1', 'app1', 'Root App 1')
self.init_ptah()
request = DummyRequest()
request.request_iface = self.registry.getUtility(
IRouteRequest, name=ptahcms.manage.MANAGE_APP_ROUTE)
interface.directlyProvides(request, request.request_iface)
mod = ApplicationsModule(None, request)
item = mod['app1']
res = render_view_to_response(item, request)
self.assertIn('<h1>Application: Root App 1</h1>', res.text)
self.assertIn('<td>Root App 1</td>', res.text)
示例2: test_apps_view
# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import request_iface [as 别名]
def test_apps_view(self):
from ptah.manage.apps import ApplicationsModule
from ptah.manage.apps import ApplicationsModuleView
cms.ApplicationFactory(
TestApp1, '/test1', 'app1', 'Root App 1')
cms.ApplicationFactory(
TestApp2, '/test2', 'app2', 'Root App 2')
self.init_ptah()
request = DummyRequest()
request.request_iface = IRequest
mod = ApplicationsModule(None, request)
res = render_view_to_response(mod, request, '', False)
self.assertEqual(res.status, '200 OK')
self.assertIn('/test1/', res.text)
self.assertIn('/test2/', res.text)
self.assertIn('App1', res.text)
self.assertIn('App2', res.text)