本文整理匯總了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")