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

Python testutil.create_request函数代码示例

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

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



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

示例1: test_json_output

    def test_json_output(self):
        testutil.create_request("/test?tg_format=json")
        import simplejson

        values = simplejson.loads(cherrypy.response.body[0])
        assert values == dict(title="Foobar", mybool=False, someval="niggles", tg_flash=None)
        assert cherrypy.response.headers["Content-Type"] == "application/json"
开发者ID:dikoufu,项目名称:turbogears,代码行数:7,代码来源:test_controllers.py


示例2: test_explicit_json

 def test_explicit_json(self):
     testutil.create_request("/explicitjson")
     assert '"title": "Blub"' in cherrypy.response.body[0]
     assert cherrypy.response.headers["Content-Type"] == "application/json"
     testutil.create_request("/explicitjson?tg_format=json")
     assert '"title": "Blub"' in cherrypy.response.body[0]
     assert cherrypy.response.headers["Content-Type"] == "application/json"
开发者ID:dikoufu,项目名称:turbogears,代码行数:7,代码来源:test_controllers.py


示例3: test_decoratator_in_restricted_subdirectory

 def test_decoratator_in_restricted_subdirectory(self):
     """Test that we can require a different permission
     in a protected subdirectory."""
     testutil.create_request('/peon_area/in_other_group?'
         'user_name=samIam&password=secret&login=Login')
     firstline = cherrypy.response.body[0]
     assert 'in_other_group' in firstline, firstline
开发者ID:OnShift,项目名称:turbogears,代码行数:7,代码来源:test_identity.py


示例4: test_explicit_checks_in_restricted_subdirectory

 def test_explicit_checks_in_restricted_subdirectory(self):
     """Test that explicit permission checks in a protected
     directory is handled as expected"""
     testutil.create_request('/peon_area/in_other_group_explicit_check?'
         'user_name=samIam&password=secret&login=Login')
     firstline = cherrypy.response.body[0]
     assert 'in_other_group' in firstline, firstline
开发者ID:OnShift,项目名称:turbogears,代码行数:7,代码来源:test_identity.py


示例5: test_old_visit

 def test_old_visit(self):
     """Test if we can track a visitor over time."""
     testutil.create_request("/")
     # first visit's cookie
     morsel = cherrypy.response.simple_cookie[self.cookie_name]
     testutil.create_request("/", headers=cookie_header(morsel))
     assert not visit.current().is_new
开发者ID:OnShift,项目名称:turbogears,代码行数:7,代码来源:test_visit.py


示例6: test_recursiveErrorHandler

 def test_recursiveErrorHandler(self):
     """Recursive error handler."""
     testutil.create_request("/recursiveerror?bar=abc")
     self.failUnless("Recursive error handler" in cherrypy.response.body[0])
     testutil.create_request("/recursiveerror?bar=1")
     self.failUnless("Recursive error provider" in
                     cherrypy.response.body[0])
开发者ID:OnShift,项目名称:turbogears,代码行数:7,代码来源:test_errorhandling.py


示例7: test_user_not_in_right_group

 def test_user_not_in_right_group(self):
     """Test that a user is denied access if they aren't in the right group."""
     testutil.create_request('/in_admin_group?'
         'user_name=samIam&password=secret&login=Login')
     firstline = cherrypy.response.body[0]
     assert 'identity_failed_answer' in firstline, firstline
     assert cherrypy.response.status == "401 Unauthorized"
开发者ID:OnShift,项目名称:turbogears,代码行数:7,代码来源:test_identity.py


示例8: test_basic_urls

 def test_basic_urls(self):
     testutil.create_request("/")
     assert "/foo" == url("/foo")
     assert "foo/bar" == url(["foo", "bar"])
     assert url("/foo", bar=1, baz=2) in ["/foo?bar=1&baz=2", "/foo?baz=2&bar=1"]
     assert url("/foo", dict(bar=1, baz=2)) in ["/foo?bar=1&baz=2", "/foo?baz=2&bar=1"]
     assert url("/foo", dict(bar=1, baz=None)) == "/foo?bar=1"
开发者ID:dikoufu,项目名称:turbogears,代码行数:7,代码来源:test_controllers.py


示例9: test_require_group

 def test_require_group(self):
     """Test that an anonymous user can not access resource protected by
     require(in_group(...))"""
     testutil.create_request('/in_peon_group')
     firstline = cherrypy.response.body[0]
     assert 'identity_failed_answer' in firstline, firstline
     assert cherrypy.response.status == "401 Unauthorized"
开发者ID:OnShift,项目名称:turbogears,代码行数:7,代码来源:test_identity.py


示例10: test_require_group_viewable

 def test_require_group_viewable(self):
     """Test that a user with proper group membership can see a restricted url."""
     testutil.create_request('/in_peon_group?'
         'user_name=samIam&password=secret&login=Login')
     firstline = cherrypy.response.body[0]
     assert 'in_peon_group' in firstline, firstline
     user = TG_User.by_user_name("samIam")
开发者ID:OnShift,项目名称:turbogears,代码行数:7,代码来源:test_identity.py


示例11: test_deny_anonymous_viewable

 def test_deny_anonymous_viewable(self):
     """Test that a logged in user can see an resource blocked
     from anonymous users."""
     testutil.create_request('/logged_in_only?'
         'user_name=samIam&password=secret&login=Login')
     firstline = cherrypy.response.body[0]
     assert 'logged_in_only' in firstline, firstline
开发者ID:OnShift,项目名称:turbogears,代码行数:7,代码来源:test_identity.py


示例12: test_old_visit

 def test_old_visit(self):
     "Test if we can track a visitor over time."
     testutil.create_request("/")
     morsel = cherrypy.response.simple_cookie[self.cookie_name] #first visit's cookie
     testutil.create_request("/", headers=cookie_header(morsel))
     assert not turbogears.visit.current().is_new
     turbogears.startup.stopTurboGears()
开发者ID:thraxil,项目名称:gtreed,代码行数:7,代码来源:test_visit.py


示例13: request

 def request(self, url):
     create_request(url)
     self.body = cherrypy.response.body[0]
     self.status = cherrypy.response.status
     if "fail: " in self.body:
         print self.body
         assert False, "Spy alert! Check body output for details..."
开发者ID:OnShift,项目名称:turbogears,代码行数:7,代码来源:test_paginate.py


示例14: test_flash_unicode

 def test_flash_unicode(self):
     """flash with unicode objects should work"""
     testutil.create_request("/flash_unicode?tg_format=json")
     import simplejson
     values = simplejson.loads(cherrypy.response.body[0])
     assert values["tg_flash"] == u"\xfcnicode"
     assert not cherrypy.response.simple_cookie.has_key("tg_flash")
开发者ID:OnShift,项目名称:turbogears,代码行数:7,代码来源:test_controllers.py


示例15: test_user_lacks_permission

 def test_user_lacks_permission(self):
     """Test that a user is denied acces if they don't have the proper permission."""
     testutil.create_request('/has_boss_permission?'
         'user_name=samIam&password=secret&login=Login')
     firstline = cherrypy.response.body[0]
     assert 'identity_failed_answer' in firstline, firstline
     assert cherrypy.response.status == "401 Unauthorized"
开发者ID:OnShift,项目名称:turbogears,代码行数:7,代码来源:test_identity.py


示例16: test_validation_nested

 def test_validation_nested(self):
     """Validation is not repeated in nested method call"""
     cherrypy.root.value = None
     testutil.create_request("/nestedcall?value=true")
     assert cherrypy.root.value == "True"
     testutil.create_request("/nestedcall?value=false")
     assert cherrypy.root.value == "False"
开发者ID:dikoufu,项目名称:turbogears,代码行数:7,代码来源:test_controllers.py


示例17: test_bad_login

 def test_bad_login(self):
     """Test that we are denied access if we provide a bad login."""
     testutil.create_request('/logged_in_only?'
         'user_name=samIam&password=wrong&login=Login')
     firstline = cherrypy.response.body[0]
     assert 'identity_failed_answer' in firstline, firstline
     assert cherrypy.response.status == "401 Unauthorized"
开发者ID:OnShift,项目名称:turbogears,代码行数:7,代码来源:test_identity.py


示例18: test_redirect_to_path

 def test_redirect_to_path(self):
     for path_type in ("str", "list", "tuple"):
         for path in ("subthing", "/subthing"):
             url = "/redirect_to_path_%s?path=%s" % (path_type, path)
             testutil.create_request(url)
             assert cherrypy.response.status.startswith("302"), url
             assert cherrypy.response.headers["Location"] == "http://localhost/subthing/index", url
开发者ID:dikoufu,项目名称:turbogears,代码行数:7,代码来源:test_controllers.py


示例19: test_restricted_subdirectory_viewable

 def test_restricted_subdirectory_viewable(self):
     """Test that we can access a restricted subdirectory
     if we have proper credentials."""
     testutil.create_request('/peon_area/index?'
         'user_name=samIam&password=secret&login=Login')
     firstline = cherrypy.response.body[0]
     assert 'restricted_index' in firstline, firstline
开发者ID:OnShift,项目名称:turbogears,代码行数:7,代码来源:test_identity.py


示例20: test_required_fields

def test_required_fields():
    """
    Required field are automatically discovered from the form validator and marked
    with the "requiredfield" css class.
    """
    class MyFields(widgets.WidgetsList):
        name = widgets.TextField(validator=validators.String())
        comment = widgets.TextArea(validator=validators.String(not_empty=True))
    form = widgets.TableForm(fields=MyFields())

    class MyRoot(turbogears.controllers.RootController):
        def test(self):
            return dict(form=form)
        test = turbogears.expose(template=".form")(test)

    cherrypy.root = MyRoot()
    testutil.create_request("/test")
    output = cherrypy.response.body[0].lower()

    print output
    name_p = 'name="comment"'
    class_p = 'class="textarea requiredfield"'
    assert (re.compile('.*'.join([class_p, name_p])).search(output) or
            re.compile('.*'.join([name_p, class_p])).search(output)
    )
    name_p = 'name="name"'
    class_p = 'class="textfield"'
    assert (re.compile('.*'.join([class_p, name_p])).search(output) or
            re.compile('.*'.join([name_p, class_p])).search(output)
    )
开发者ID:OnShift,项目名称:turbogears,代码行数:30,代码来源:test_request_related_features.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python jsonify.jsonify_sqlobject函数代码示例发布时间:2022-05-27
下一篇:
Python testutil.createRequest函数代码示例发布时间: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