當前位置: 首頁>>代碼示例>>Python>>正文


Python DummyRequest.write方法代碼示例

本文整理匯總了Python中shiji.testutil.DummyRequest.write方法的典型用法代碼示例。如果您正苦於以下問題:Python DummyRequest.write方法的具體用法?Python DummyRequest.write怎麽用?Python DummyRequest.write使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在shiji.testutil.DummyRequest的用法示例。


在下文中一共展示了DummyRequest.write方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_json_validate_success

# 需要導入模塊: from shiji.testutil import DummyRequest [as 別名]
# 或者: from shiji.testutil.DummyRequest import write [as 別名]
 def test_json_validate_success(self):
     "Request JSON arguments successfully validated."
     test_request = DummyRequest()
     test_request.setHeader("Content-Type", "application/json; charset=utf-8")
     test_request.write(json.dumps({"arg1" : unicode("hi")}))
     self.dummy_render_func2(test_request)
     self.assertTrue(hasattr(test_request, "jsonArgs"))
     self.assertTrue(test_request.jsonArgs.has_key("arg1"))
     self.assertEqual(test_request.jsonArgs["arg1"], unicode("hi"))
開發者ID:notoriousno,項目名稱:shiji,代碼行數:11,代碼來源:test_webapi.py

示例2: test_content_required_arg_missing_optional_flag_false

# 需要導入模塊: from shiji.testutil import DummyRequest [as 別名]
# 或者: from shiji.testutil.DummyRequest import write [as 別名]
 def test_content_required_arg_missing_optional_flag_false(self):
     "Request JSON arguments missing required argument."
     test_request = DummyRequest()
     test_request.setHeader("Content-Type", "application/json; charset=utf-8")
     test_request.write(json.dumps({"arg2" : 1}))
     outer_wrap = webapi.json_arguments([("arg1", unicode, False)])
     inner_wrap = outer_wrap(self.dummy_render_func)
     self.assertEqual(str(webapi.ValueError(test_request, "arg1", "Argument is missing.")),
                      inner_wrap(self, test_request))
開發者ID:notoriousno,項目名稱:shiji,代碼行數:11,代碼來源:test_webapi.py

示例3: test_content_not_dict

# 需要導入模塊: from shiji.testutil import DummyRequest [as 別名]
# 或者: from shiji.testutil.DummyRequest import write [as 別名]
 def test_content_not_dict(self):
     "Request content contained in a dictionary/hash."
     test_request = DummyRequest()
     test_request.setHeader("Content-Type", "application/json; charset=utf-8")
     test_request.write(json.dumps("not a dict"))
     outer_wrap = webapi.json_arguments([("arg1", unicode)])
     inner_wrap = outer_wrap(self.dummy_render_func)
     self.assertEqual(str(webapi.RequestNotHashError(test_request)),
                      inner_wrap(self, test_request))
開發者ID:notoriousno,項目名稱:shiji,代碼行數:11,代碼來源:test_webapi.py

示例4: test_content_arg_type_mismatch_optional_arg

# 需要導入模塊: from shiji.testutil import DummyRequest [as 別名]
# 或者: from shiji.testutil.DummyRequest import write [as 別名]
 def test_content_arg_type_mismatch_optional_arg(self):
     "Request JSON optional arguments contain data which doesn't match expected type."
     test_request = DummyRequest()
     test_request.setHeader("Content-Type", "application/json; charset=utf-8")
     test_request.write(json.dumps({"arg1" : 1}))
     outer_wrap = webapi.json_arguments([("arg1", unicode, True)])
     inner_wrap = outer_wrap(self.dummy_render_func)
     self.assertEqual(str(webapi.ValueError(test_request, "arg1", "Must be of type unicode")),
                      inner_wrap(self, test_request))
開發者ID:notoriousno,項目名稱:shiji,代碼行數:11,代碼來源:test_webapi.py

示例5: test_content_invalid_json

# 需要導入模塊: from shiji.testutil import DummyRequest [as 別名]
# 或者: from shiji.testutil.DummyRequest import write [as 別名]
 def test_content_invalid_json(self):
     "Request content not valid JSON."
     test_request = DummyRequest()
     test_request.setHeader("Content-Type", "application/json; charset=utf-8")
     test_request.write("boingo! bad json!")
     outer_wrap = webapi.json_arguments([("arg1", unicode)])
     inner_wrap = outer_wrap(self.dummy_render_func)
     self.assertEqual(str(webapi.JSONDecodeError(test_request)),
                      inner_wrap(self, test_request))
開發者ID:notoriousno,項目名稱:shiji,代碼行數:11,代碼來源:test_webapi.py


注:本文中的shiji.testutil.DummyRequest.write方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。