本文整理汇总了Python中shiji.testutil.DummyRequest.method方法的典型用法代码示例。如果您正苦于以下问题:Python DummyRequest.method方法的具体用法?Python DummyRequest.method怎么用?Python DummyRequest.method使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shiji.testutil.DummyRequest
的用法示例。
在下文中一共展示了DummyRequest.method方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_options
# 需要导入模块: from shiji.testutil import DummyRequest [as 别名]
# 或者: from shiji.testutil.DummyRequest import method [as 别名]
def test_get_options(self):
"Test OPTIONS request."
route_map = [(r"^/example/", dummy_api)]
api_config = {"arg1" : True, "arg2" : 42}
request = DummyRequest(api_mode="prod", api_version="1.0", api_name="dummy_api")
request.method = "OPTIONS"
request.setHeader("Access-Control-Request-Headers", "Content-Type")
router = urldispatch.APIRouter(route_map, config=api_config, cross_origin_domains="*")
resource = router.getChild("/example/", request)
self.assertTrue(isinstance(resource, urldispatch.CORSInterrogation))
resource.render_OPTIONS(request)
self.assertEquals(request.getHeader("Content-Type"),
"application/json; charset=utf-8")
self.assertEquals(request.getHeader("Access-Control-Allow-Origin"),
"*")
self.assertEquals(request.getHeader("Access-Control-Allow-Credentials"),
"true")
self.assertEquals(request.getHeader("Access-Control-Allow-Headers"),
"Content-Type")
self.assertEquals(request.getHeader("Access-Control-Allow-Methods"),
"PUT,GET,DELETE,POST,HEAD,TRACE,CONNECT,PROPFIND,PROPPATCH,MKCOL,COPY,MOVE,LOCK,UNLOCK")