当前位置: 首页>>代码示例>>Python>>正文


Python DummyRequest.layout_manager方法代码示例

本文整理汇总了Python中pyramid.testing.DummyRequest.layout_manager方法的典型用法代码示例。如果您正苦于以下问题:Python DummyRequest.layout_manager方法的具体用法?Python DummyRequest.layout_manager怎么用?Python DummyRequest.layout_manager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyramid.testing.DummyRequest的用法示例。


在下文中一共展示了DummyRequest.layout_manager方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_it

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import layout_manager [as 别名]
    def test_it(self):
        registerLayoutProvider()
        self._registerTagbox()

        context = self.context
        request = DummyRequest()
        request.layout_manager = mock.Mock()

        renderer = karl.testing.registerDummyRenderer(self.template_fn)
        self._callFUT(context, request)
        self.assertEqual(renderer.api.page_title, 'dummytitle')
        self.assertEqual(len(renderer.actions), 3)
        self.assertEqual(renderer.actions[0][1], 'edit.html')
        self.assertEqual(renderer.actions[1][1], 'delete.html')
开发者ID:hj91,项目名称:karl,代码行数:16,代码来源:test_page.py

示例2: test_it

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import layout_manager [as 别名]
    def test_it(self):
        import mock
        from zope.interface import Interface
        from zope.interface import alsoProvides
        from pyramid.testing import DummyModel
        from pyramid.testing import DummyRequest
        from karl.models.interfaces import ICommunity
        from karl.models.interfaces import ISite
        from karl.models.interfaces import IIntranet
        from karl.models.interfaces import IIntranets
        from karl.views.interfaces import IIntranetPortlet
        from karl.testing import registerAdapter
        from karl.testing import registerDummyRenderer
        ANY = (Interface, Interface)
        WELL = u'<h1>WELL</h1>'
        BODY = u'<h1>BODY</h1>'
        FEATURE = u'<p>FEATURE</p>'
        root = DummyModel()
        alsoProvides(root, ISite)
        offices = root['offices'] = DummyModel()
        alsoProvides(offices, IIntranets)
        offices.feature = FEATURE
        context = offices['nice'] = DummyModel(title='nice office')
        context['foo'] = DummyModel()
        context['bar'] = DummyModel()
        context['spam'] = DummyModel()
        alsoProvides(context, ICommunity)
        alsoProvides(context, IIntranet)
        context.middle_portlets = ['foo', 'bar|baz']
        context.right_portlets = ['spam|qux']
        request = DummyRequest()
        request.layout_manager = mock.Mock()

        class _Portlet(object):
            def __init__(self, text):
                self._text = text
            @property
            def asHTML(self):
                return self._text

        _nameless_contexts = []
        NAMELESS = '<p>NAMELESS</p>'
        def _nameless(context, req):
            assert req is request
            _nameless_contexts.append(context)
            return _Portlet(NAMELESS)
        registerAdapter(_nameless, ANY, IIntranetPortlet)

        _baz_contexts = []
        BAZ = '<p>BAZ</p>'
        def _baz(context, req):
            assert req is request
            _baz_contexts.append(context)
            return _Portlet(BAZ)
        registerAdapter(_baz, ANY, IIntranetPortlet, name='baz')

        _qux_contexts = []
        QUX = '<p>QUX</p>'
        def _qux(context, req):
            assert req is request
            _qux_contexts.append(context)
            return _Portlet(QUX)
        registerAdapter(_qux, ANY, IIntranetPortlet, name='qux')

        _ihb_data = []
        def _IHB(data, _):
            _ihb_data.append(data)
            return WELL
        registerDummyRenderer(
            'karl.views:templates/intranethome_body.pt', _IHB)

        _ihp_data = []
        def _IHP(data, _):
            _ihp_data.append(data)
            return BODY
        registerDummyRenderer(
            'karl.views:templates/intranet_homepage.pt', _IHP)

        response = self._callFUT(context, request)
        self.assertEqual(response.body, BODY)
        self.assertEqual(len(_ihp_data), 1)
        self.assertEqual(_ihp_data[0]['body'], WELL)
        self.assertEqual(len(_ihb_data), 1)
        self.assertTrue(_ihb_data[0]['current_intranet'] is context)
        self.assertEqual(_ihb_data[0]['feature'], FEATURE)
        self.assertEqual(_ihb_data[0]['middle_portlet_html'], NAMELESS + BAZ)
        self.assertEqual(_ihb_data[0]['right_portlet_html'], QUX)
开发者ID:mindreframer,项目名称:python-pyramid-stuff,代码行数:89,代码来源:test_retail.py


注:本文中的pyramid.testing.DummyRequest.layout_manager方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。