• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python testapi.request函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中testapi.request函数的典型用法代码示例。如果您正苦于以下问题:Python request函数的具体用法?Python request怎么用?Python request使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_rw_corrupt

 def test_rw_corrupt(self):
     testapi.request(1)
     try:
         repeating_widget.validate({"a": {"a": "b"}})
         assert False
     except twc.ValidationError:
         pass
开发者ID:nphilipp,项目名称:tw2.core,代码行数:7,代码来源:test_validation.py


示例2: test_mime_type

 def test_mime_type(self):
     testapi.request(1, mw)
     wa = twc.JSLink(modname='tw2.core', filename='test_templates/simple_genshi.html').req()
     wa.prepare()
     resp = tst_mw.get(wa.link)
     assert(resp.content_type == 'text/html')
     assert(resp.charset == 'UTF-8')
开发者ID:LeResKP,项目名称:tw2.core,代码行数:7,代码来源:test_resources.py


示例3: test_round_trip

    def test_round_trip(self):
        test = twc.CompoundWidget(
            id="a",
            children=[
                twc.DisplayOnlyWidget(child=twc.RepeatingWidget(id="q", child=twc.Widget)),
                twc.CompoundWidget(id="cc", children=[twc.Widget(id="d"), twc.Widget(id="e")]),
            ],
        )

        widgets = [
            test.children[0].child.rwbc[0],
            test.children[0].child.rwbc[1],
            test.children.cc.children.d,
            test.children.cc.children.e,
        ]

        data = dict((w.compound_id, "test%d" % i) for i, w in enumerate(widgets))
        testapi.request(1)
        vdata = test.validate(data)

        test = twc.core.request_local()["validated_widget"]
        widgets = [
            test.children[0].child.children[0],
            test.children[0].child.children[1],
            test.children.cc.children.d,
            test.children.cc.children.e,
        ]

        for i, w in enumerate(widgets):
            eq_(w.value, "test%d" % i)
开发者ID:nphilipp,项目名称:tw2.core,代码行数:30,代码来源:test_validation.py


示例4: test_compound_corrupt

 def test_compound_corrupt(self):
     testapi.request(1)
     try:
         compound_widget.validate({'a':[]})
         assert(False)
     except twc.ValidationError:
         pass
开发者ID:clsdaniel,项目名称:tw2.core,代码行数:7,代码来源:test_validation.py


示例5: test_rw_propagate

 def test_rw_propagate(self):
     test = twc.RepeatingWidget(child=twc.Widget).req()
     testapi.request(1)
     test.value = ['a', 'b', 'c']
     test.prepare()
     assert(len(test.children) == 3)
     assert([w.value for w in test.children] == ['a', 'b', 'c'])
开发者ID:lmacken,项目名称:tw2.core,代码行数:7,代码来源:test_hierarchy.py


示例6: test_rw_corrupt

 def test_rw_corrupt(self):
     testapi.request(1)
     try:
         repeating_widget.validate({'a':{'a':'b'}})
         assert(False)
     except twc.ValidationError:
         pass
开发者ID:clsdaniel,项目名称:tw2.core,代码行数:7,代码来源:test_validation.py


示例7: test_rw_child_fail

 def test_rw_child_fail(self):
     testapi.request(1)
     try:
         repeating_widget.validate({'a':['test', '']})
         assert(False)
     except twc.ValidationError, e:
         pass
开发者ID:clsdaniel,项目名称:tw2.core,代码行数:7,代码来源:test_validation.py


示例8: test_round_trip

    def test_round_trip(self):
        test = twc.CompoundWidget(id='a', children=[
            twc.DisplayOnlyWidget(child=
                twc.RepeatingWidget(id='q', child=twc.Widget)
            ),
            twc.CompoundWidget(id='cc', children=[
                twc.Widget(id='d'),
                twc.Widget(id='e'),
            ])
        ])

        widgets = [
            test.children[0].child.rwbc[0],
            test.children[0].child.rwbc[1],
            test.children.cc.children.d,
            test.children.cc.children.e,
        ]

        data = dict((w.compound_id, 'test%d' % i) for i,w in enumerate(widgets))
        testapi.request(1)
        vdata = test.validate(data)

        test = twc.core.request_local()['validated_widget']
        widgets = [
            test.children[0].child.children[0],
            test.children[0].child.children[1],
            test.children.cc.children.d,
            test.children.cc.children.e,
        ]

        for i,w in enumerate(widgets):
            eq_(w.value, 'test%d' % i)
开发者ID:clsdaniel,项目名称:tw2.core,代码行数:32,代码来源:test_validation.py


示例9: testTGStyleController

    def testTGStyleController(self):
        """ Test turbogears style dispatch """
        from tw2.core.middleware import ControllersApp, TwMiddleware
        from tw2.core.compat import TGStyleController

        controller_response = Response("CONTROLLER")

        class WidgetMock(TGStyleController):
            id = "fake"

            class Controller(object):
                def foobar(self, request):
                    return controller_response

        mock = WidgetMock()
        mw = TwMiddleware(None, controller_prefix="goo")
        testapi.request(1, mw)
        ca = ControllersApp()

        ca.register(mock)
        res = ca(Request.blank("/%s/%s/foobar" % (mw.config.controller_prefix, mock.id)))
        self.assert_(res.status_int == 200, res.status_int)
        self.assert_(res.body == controller_response.body, res.body)

        res = ca(Request.blank("/%s/404" % mw.config.controller_prefix))
        self.assert_(res.status_int == 404, res.status_int)
        res = ca(Request.blank("%s/404" % mw.config.controller_prefix))
        self.assert_(res.status_int == 404, res.status_int)
开发者ID:RobertSudwarts,项目名称:tw2.core,代码行数:28,代码来源:test_middleware.py


示例10: testControllerAppWithId

    def testControllerAppWithId(self):
        """
        controllerapp should dispatch to an object having id, and a
        request method taking a webob request based on path_info of
        request.
        """
        from tw2.core.middleware import ControllersApp, TwMiddleware

        controller_response = Response("CONTROLLER")

        class WidgetMock(object):
            def __init__(self):
                self.id = "fake"

            def request(self, request):
                return controller_response

        mock = WidgetMock()
        mw = TwMiddleware(None, controller_prefix="goo")
        testapi.request(1, mw)
        ca = ControllersApp()

        ca.register(mock)
        res = ca(Request.blank("/%s/%s" % (mw.config.controller_prefix, mock.id)))
        self.assert_(res.status_int == 200, res.status_int)
        self.assert_(res.body == controller_response.body, res.body)

        res = ca(Request.blank("/%s/404" % mw.config.controller_prefix))
        self.assert_(res.status_int == 404, res.status_int)
        res = ca(Request.blank("%s/404" % mw.config.controller_prefix))
        self.assert_(res.status_int == 404, res.status_int)
开发者ID:RobertSudwarts,项目名称:tw2.core,代码行数:31,代码来源:test_middleware.py


示例11: test_rw_propagate

 def test_rw_propagate(self):
     test = twc.RepeatingWidget(child=Child).req()
     testapi.request(1)
     test.value = ["a", "b", "c"]
     test.prepare()
     assert len(test.children) == 3
     assert [w.value for w in test.children] == ["a", "b", "c"]
开发者ID:nphilipp,项目名称:tw2.core,代码行数:7,代码来源:test_hierarchy.py


示例12: _check_render

 def _check_render(self, template, data, expected, engine=None):
     if engine:
         mw = twc.make_middleware(None, preferred_rendering_engines=[engine])
         testapi.request(1, mw)
     out = twc.template.EngineManager().render(template, 'string', data)
     assert(isinstance(out, unicode))
     assert out == expected, out
开发者ID:lmacken,项目名称:tw2.core,代码行数:7,代码来源:test_template.py


示例13: test_rw_pass

 def test_rw_pass(self):
     testapi.request(1)
     rep = repeating_widget.req()
     inp = ["test", "test2"]
     out = rep._validate(inp)
     assert inp == out
     assert rep.children[0].value == "test"
     assert rep.children[1].value == "test2"
开发者ID:nphilipp,项目名称:tw2.core,代码行数:8,代码来源:test_validation.py


示例14: test_compound_pass

 def test_compound_pass(self):
     testapi.request(1)
     inp = {"a": {"b": "test", "c": "test2"}}
     out = compound_widget.validate(inp)
     eq_(out, inp["a"])
     cw = twc.core.request_local()["validated_widget"]
     assert cw.children.b.value == "test"
     assert cw.children.c.value == "test2"
开发者ID:nphilipp,项目名称:tw2.core,代码行数:8,代码来源:test_validation.py


示例15: test_rwb

 def test_rwb(self):
     test = twc.RepeatingWidget(child=twc.Widget).req()
     testapi.request(1)
     test.value = ['a', 'b', 'c']
     test.prepare()
     for i in range(4):
         assert(test.children[i].repetition == i)
     assert(test.children[0] is not test.children[1])
开发者ID:lmacken,项目名称:tw2.core,代码行数:8,代码来源:test_hierarchy.py


示例16: test_rwb

 def test_rwb(self):
     test = twc.RepeatingWidget(child=Child(template=None)).req()
     testapi.request(1)
     test.value = ["a", "b", "c"]
     test.prepare()
     for i in range(4):
         assert test.children[i].repetition == i
     assert test.children[0] is not test.children[1]
开发者ID:nphilipp,项目名称:tw2.core,代码行数:8,代码来源:test_hierarchy.py


示例17: test_compound_keyed_children

 def test_compound_keyed_children(self):
     testapi.request(1)
     inp = {'a': {'x':'test', 'y':'test2'}}
     try:
         compound_keyed_widget.validate(inp)
         assert False
     except twc.ValidationError, e:
         pass
开发者ID:clsdaniel,项目名称:tw2.core,代码行数:8,代码来源:test_validation.py


示例18: test_rw_pass

 def test_rw_pass(self):
     testapi.request(1)
     rep = repeating_widget.req()
     inp = ['test', 'test2']
     out = rep._validate(inp)
     assert(inp == out)
     assert(rep.children[0].value == 'test')
     assert(rep.children[1].value == 'test2')
开发者ID:clsdaniel,项目名称:tw2.core,代码行数:8,代码来源:test_validation.py


示例19: test_compound_pass

 def test_compound_pass(self):
     testapi.request(1)
     inp = {'a': {'b':'test', 'c':'test2'}}
     out = compound_widget.validate(inp)
     eq_(out, inp['a'])
     cw = twc.core.request_local()['validated_widget']
     assert(cw.children.b.value == 'test')
     assert(cw.children.c.value == 'test2')
开发者ID:clsdaniel,项目名称:tw2.core,代码行数:8,代码来源:test_validation.py


示例20: _check_render

    def _check_render(self, template, data, expected, engine=None):
        if engine:
            mw = twc.make_middleware(None, preferred_rendering_engines=[engine])
            testapi.request(1, mw)
            twc.util.flush_memoization()

        out = twc.templating.render(template, "string", data)
        assert isinstance(out, six.text_type)
        eq_(out, expected)
开发者ID:toscawidgets,项目名称:tw2.core,代码行数:9,代码来源:test_template.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python testbabel.run_exec函数代码示例发布时间:2022-05-27
下一篇:
Python testable.register函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap