本文整理汇总了Python中turbogears.testutil.createRequest函数的典型用法代码示例。如果您正苦于以下问题:Python createRequest函数的具体用法?Python createRequest怎么用?Python createRequest使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了createRequest函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_flash_unicode
def test_flash_unicode(self):
"turbogears.flash with unicode objects should work"
testutil.createRequest("/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:thraxil,项目名称:gtreed,代码行数:7,代码来源:test_controllers.py
示例2: test_rows_column_number
def test_rows_column_number(self):
#Control that the number of columns match the number of fields in the model
cherrypy.root.catwalk = CatWalk(browse)
testutil.createRequest("/catwalk/browse/?object_name=Artist&tg_format=json")
response = cherrypy.response.body[0]
values = simplejson.loads(response)
assert len(values['rows'][0]) == 4
开发者ID:thraxil,项目名称:gtreed,代码行数:7,代码来源:test_catwalk.py
示例3: test_recursiveErrorHandler
def test_recursiveErrorHandler(self):
""" Recursive error handler. """
testutil.createRequest("/recursiveerror?bar=abc")
self.failUnless("Recursive error handler" in cherrypy.response.body[0])
testutil.createRequest("/recursiveerror?bar=1")
self.failUnless("Recursive error provider" in
cherrypy.response.body[0])
开发者ID:thraxil,项目名称:gtreed,代码行数:7,代码来源:test_errorhandling.py
示例4: test_jsonOutput
def test_jsonOutput(self):
testutil.createRequest("/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"] == "text/javascript"
开发者ID:thraxil,项目名称:gtreed,代码行数:7,代码来源:test_controllers.py
示例5: test_index_trailing_slash
def test_index_trailing_slash():
"If there is no trailing slash on an index method call, redirect"
cherrypy.root = SubApp()
cherrypy.root.foo = SubApp()
testutil.createRequest("/foo")
print cherrypy.response.status
assert cherrypy.response.status.startswith("302")
开发者ID:thraxil,项目名称:gtreed,代码行数:7,代码来源:test_controllers.py
示例6: test_approotsWithPath
def test_approotsWithPath(self):
turbogears.config.update({"server.webpath" : "/coolsite/root"})
turbogears.startup.startTurboGears()
testutil.createRequest("/coolsite/root/subthing/")
print cherrypy.tree.mount_point()
self.failUnlessEqual("/coolsite/root/subthing/foo",
url("/foo"))
开发者ID:thraxil,项目名称:gtreed,代码行数:7,代码来源:test_controllers.py
示例7: 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.createRequest("/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:thraxil,项目名称:gtreed,代码行数:30,代码来源:test_request_related_features.py
示例8: test_flash_plain
def test_flash_plain(self):
"turbogears.flash with strings should work"
testutil.createRequest("/flash_plain?tg_format=json")
import simplejson
values = simplejson.loads(cherrypy.response.body[0])
assert values["tg_flash"]=="plain"
assert not cherrypy.response.simple_cookie.has_key("tg_flash")
开发者ID:thraxil,项目名称:gtreed,代码行数:7,代码来源:test_controllers.py
示例9: test_runwithtrans
def test_runwithtrans(self):
"run_with_transaction is called only on topmost exposed method"
oldrwt = database.run_with_transaction
database.run_with_transaction = cherrypy.root.rwt
testutil.createRequest("/callsanother")
database.run_with_transaction = oldrwt
assert cherrypy.root.value
assert cherrypy.root.rwt_called == 1
开发者ID:thraxil,项目名称:gtreed,代码行数:8,代码来源:test_controllers.py
示例10: test_defaultFormat
def test_defaultFormat(self):
"""The default format can be set via expose"""
testutil.createRequest("/returnjson")
firstline = cherrypy.response.body[0]
assert '"title": "Foobar"' in firstline
testutil.createRequest("/returnjson?tg_format=html")
firstline = cherrypy.response.body[0]
assert '"title": "Foobar"' not in firstline
开发者ID:thraxil,项目名称:gtreed,代码行数:8,代码来源:test_controllers.py
示例11: test_include_widgets
def test_include_widgets():
"Any widget Can be included everywhere by setting tg.include_widgets"
root = cherrypy.root
turbogears.config.update({"global":{"tg.include_widgets" : ["turbogears.mochikit"]}})
testutil.createRequest("/")
turbogears.config.update({"global":{"tg.include_widgets" : None}})
print cherrypy.response.body[0]
assert "MochiKit.js" in cherrypy.response.body[0]
开发者ID:thraxil,项目名称:gtreed,代码行数:8,代码来源:test_form_controllers.py
示例12: test_form_translation
def test_form_translation():
"Form input is translated into properly converted parameters"
root = MyRoot()
cherrypy.root = root
testutil.createRequest("/testform?name=ed&date=11/05/2005&age=5")
assert root.name == "ed"
print root.age
assert root.age == 5
开发者ID:thraxil,项目名称:gtreed,代码行数:8,代码来源:test_form_controllers.py
示例13: test_mochikit_everywhere
def test_mochikit_everywhere():
"MochiKit can be included everywhere by setting tg.mochikit_all"
root = cherrypy.root
turbogears.config.update({"global":{"tg.mochikit_all" : True}})
testutil.createRequest("/")
turbogears.config.update({"global":{"tg.mochikit_all" : False}})
print cherrypy.response.body[0]
assert "MochiKit.js" in cherrypy.response.body[0]
开发者ID:thraxil,项目名称:gtreed,代码行数:8,代码来源:test_form_controllers.py
示例14: test_implicitErrorHandler
def test_implicitErrorHandler(self):
""" Implicit error handling. """
testutil.createRequest("/impliciterror?bar=abc")
self.failUnless("Implicit error handler" in
cherrypy.response.body[0])
testutil.createRequest("/impliciterror?bar=1")
self.failUnless("Implicit error provider" in
cherrypy.response.body[0])
开发者ID:thraxil,项目名称:gtreed,代码行数:8,代码来源:test_errorhandling.py
示例15: test_set_kid_outputformat_in_config
def test_set_kid_outputformat_in_config(self):
"the outputformat for kid can be set in the config"
turbogears.config.update({'kid.outputformat': 'xhtml'})
testutil.createRequest('/test')
assert '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML ' in cherrypy.response.body[0]
turbogears.config.update({'kid.outputformat': 'html'})
testutil.createRequest('/test')
assert '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML ' in cherrypy.response.body[0]
开发者ID:thraxil,项目名称:gtreed,代码行数:8,代码来源:test_controllers.py
示例16: test_form_translation_new_style
def test_form_translation_new_style():
"Form input is translated into properly converted parameters"
root = MyRoot()
cherrypy.root = root
testutil.createRequest("/testform_new_style?p_data.name=ed&p_data.age=5")
assert root.name == "ed"
print root.age
assert root.age == 5
开发者ID:thraxil,项目名称:gtreed,代码行数:8,代码来源:test_nested_form_controllers.py
示例17: test_addremove_related_joins
def test_addremove_related_joins(self):
# check the update_join function when nondefault add/remove are used
artist = self.model.Artist.get(1)
assert len(artist.plays_instruments) == 0
testutil.createRequest("/catwalk/updateJoins?objectName=Artist&id=1&join=plays_instruments&joinType=&joinObjectName=Instrument&joins=1%2C2&tg_format=json")
assert len(artist.plays_instruments) == 2
testutil.createRequest("/catwalk/updateJoins?objectName=Artist&id=1&join=plays_instruments&joinType=&joinObjectName=Instrument&joins=1&tg_format=json")
assert len(artist.plays_instruments) == 1, str(artist.plays_instruments)
开发者ID:thraxil,项目名称:gtreed,代码行数:8,代码来源:test_catwalk.py
示例18: test_list_contents
def test_list_contents(self):
"""If we add a record to the model, it should
show up in the final page text"""
cherrypy.root=Root()
Bookmark(name='Compound Thinking',
link='http://www.CompoundThinking.com',
description="A {not so} random link.")
testutil.createRequest("/list")
assert '<a href="http://www.CompoundThinking.com">' in cherrypy.response.body[0]
开发者ID:mantour,项目名称:myrepo,代码行数:9,代码来源:test_db.py
示例19: test_basicurls
def test_basicurls(self):
testutil.createRequest("/")
self.failUnlessEqual("/foo", url("/foo"))
self.failUnlessEqual("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:thraxil,项目名称:gtreed,代码行数:9,代码来源:test_controllers.py
示例20: test_header_labels
def test_header_labels(self):
#Check that the returned header labels match the the model
cherrypy.root.catwalk = CatWalk(browse)
testutil.createRequest("/catwalk/browse/?object_name=Artist&tg_format=json")
response = cherrypy.response.body[0]
values = simplejson.loads(response)
assert len(values['headers']) == 5
for header in values['headers']:
assert header['name'] in ['id','name','albums','genres', 'plays_instruments']
开发者ID:thraxil,项目名称:gtreed,代码行数:9,代码来源:test_catwalk.py
注:本文中的turbogears.testutil.createRequest函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论