本文整理汇总了Python中aiohttp.web.UrlDispatcher.add_patch方法的典型用法代码示例。如果您正苦于以下问题:Python UrlDispatcher.add_patch方法的具体用法?Python UrlDispatcher.add_patch怎么用?Python UrlDispatcher.add_patch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aiohttp.web.UrlDispatcher
的用法示例。
在下文中一共展示了UrlDispatcher.add_patch方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestUrlDispatcher
# 需要导入模块: from aiohttp.web import UrlDispatcher [as 别名]
# 或者: from aiohttp.web.UrlDispatcher import add_patch [as 别名]
#.........这里部分代码省略.........
self.assertIs(handler, info.handler)
self.assertIsNone(info.route.name)
def test_add_route_with_add_get_shortcut(self):
handler = self.make_handler()
self.router.add_get('/handler/to/path', handler)
req = self.make_request('GET', '/handler/to/path')
info = self.loop.run_until_complete(self.router.resolve(req))
self.assertIsNotNone(info)
self.assertEqual(0, len(info))
self.assertIs(handler, info.handler)
self.assertIsNone(info.route.name)
def test_add_route_with_add_post_shortcut(self):
handler = self.make_handler()
self.router.add_post('/handler/to/path', handler)
req = self.make_request('POST', '/handler/to/path')
info = self.loop.run_until_complete(self.router.resolve(req))
self.assertIsNotNone(info)
self.assertEqual(0, len(info))
self.assertIs(handler, info.handler)
self.assertIsNone(info.route.name)
def test_add_route_with_add_put_shortcut(self):
handler = self.make_handler()
self.router.add_put('/handler/to/path', handler)
req = self.make_request('PUT', '/handler/to/path')
info = self.loop.run_until_complete(self.router.resolve(req))
self.assertIsNotNone(info)
self.assertEqual(0, len(info))
self.assertIs(handler, info.handler)
self.assertIsNone(info.route.name)
def test_add_route_with_add_patch_shortcut(self):
handler = self.make_handler()
self.router.add_patch('/handler/to/path', handler)
req = self.make_request('PATCH', '/handler/to/path')
info = self.loop.run_until_complete(self.router.resolve(req))
self.assertIsNotNone(info)
self.assertEqual(0, len(info))
self.assertIs(handler, info.handler)
self.assertIsNone(info.route.name)
def test_add_route_with_add_delete_shortcut(self):
handler = self.make_handler()
self.router.add_delete('/handler/to/path', handler)
req = self.make_request('DELETE', '/handler/to/path')
info = self.loop.run_until_complete(self.router.resolve(req))
self.assertIsNotNone(info)
self.assertEqual(0, len(info))
self.assertIs(handler, info.handler)
self.assertIsNone(info.route.name)
def test_add_with_name(self):
handler = self.make_handler()
self.router.add_route('GET', '/handler/to/path', handler,
name='name')
req = self.make_request('GET', '/handler/to/path')
info = self.loop.run_until_complete(self.router.resolve(req))
self.assertIsNotNone(info)
self.assertEqual('name', info.route.name)
def test_add_with_tailing_slash(self):
handler = self.make_handler()
self.router.add_route('GET', '/handler/to/path/', handler)
req = self.make_request('GET', '/handler/to/path/')