当前位置: 首页>>代码示例>>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;未经允许,请勿转载。