本文整理汇总了Python中turbogears.testutil.create_request函数的典型用法代码示例。如果您正苦于以下问题:Python create_request函数的具体用法?Python create_request怎么用?Python create_request使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_request函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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"
示例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"
示例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
示例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
示例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
示例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])
示例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"
示例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"
示例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"
示例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")
示例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
示例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()
示例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..."
示例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")
示例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"