本文整理汇总了Python中brubeck.request_handling.Brubeck.route_message方法的典型用法代码示例。如果您正苦于以下问题:Python Brubeck.route_message方法的具体用法?Python Brubeck.route_message怎么用?Python Brubeck.route_message使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类brubeck.request_handling.Brubeck
的用法示例。
在下文中一共展示了Brubeck.route_message方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestRequestHandling
# 需要导入模块: from brubeck.request_handling import Brubeck [as 别名]
# 或者: from brubeck.request_handling.Brubeck import route_message [as 别名]
class TestRequestHandling(unittest.TestCase):
"""
a test class for brubeck's request_handler
"""
def setUp(self):
""" will get run for each test """
config = {
'mongrel2_pair': ('ipc://127.0.0.1:9999', 'ipc://127.0.0.1:9998'),
'msg_conn': WSGIConnection()
}
self.app = Brubeck(**config)
##
## our actual tests( test _xxxx_xxxx(self) )
##
def test_add_route_rule_method(self):
# Make sure we have no routes
self.assertEqual(hasattr(self.app,'_routes'),False)
# setup a route
self.setup_route_with_method()
# Make sure we have some routes
self.assertEqual(hasattr(self.app,'_routes'),True)
# Make sure we have exactly one route
self.assertEqual(len(self.app._routes),1)
def test_init_routes_with_methods(self):
# Make sure we have no routes
self.assertEqual(hasattr(self.app, '_routes'), False)
# Create a tuple with routes with method handlers
routes = [ (r'^/', simple_handler_method), (r'^/brubeck', simple_handler_method) ]
# init our routes
self.app.init_routes( routes )
# Make sure we have two routes
self.assertEqual(len(self.app._routes), 2)
def test_init_routes_with_objects(self):
# Make sure we have no routes
self.assertEqual(hasattr(self.app, '_routes'), False)
# Create a tuple of routes with object handlers
routes = [(r'^/', SimpleWebHandlerObject), (r'^/brubeck', SimpleWebHandlerObject)]
self.app.init_routes( routes )
# Make sure we have two routes
self.assertEqual(len(self.app._routes), 2)
def test_init_routes_with_objects_and_methods(self):
# Make sure we have no routes
self.assertEqual(hasattr(self.app, '_routes'), False)
# Create a tuple of routes with a method handler and an object handler
routes = [(r'^/', SimpleWebHandlerObject), (r'^/brubeck', simple_handler_method)]
self.app.init_routes( routes )
# Make sure we have two routes
self.assertEqual(len(self.app._routes), 2)
def test_add_route_rule_object(self):
# Make sure we have no routes
self.assertEqual(hasattr(self.app,'_routes'),False)
self.setup_route_with_object()
# Make sure we have some routes
self.assertEqual(hasattr(self.app,'_routes'),True)
# Make sure we have exactly one route
self.assertEqual(len(self.app._routes),1)
def test_brubeck_handle_request_with_object(self):
# set up our route
self.setup_route_with_object()
# Make sure we get a handler back when we request one
message = MockMessage(path='/')
handler = self.app.route_message(message)
self.assertNotEqual(handler,None)
def test_brubeck_handle_request_with_method(self):
# We ran tests on this already, so assume it works
self.setup_route_with_method()
# Make sure we get a handler back when we request one
message = MockMessage(path='/')
handler = self.app.route_message(message)
self.assertNotEqual(handler,None)
def test_cookie_handling(self):
# set our cookie key and values
cookie_key = 'my_key'
cookie_value = 'my_secret'
# encode our cookie
encoded_cookie = cookie_encode(cookie_value, cookie_key)
# Make sure we do not contain our value (i.e. we are really encrypting)
#.........这里部分代码省略.........