本文整理汇总了Python中coapthon.messages.request.Request.accept方法的典型用法代码示例。如果您正苦于以下问题:Python Request.accept方法的具体用法?Python Request.accept怎么用?Python Request.accept使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类coapthon.messages.request.Request
的用法示例。
在下文中一共展示了Request.accept方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_td_coap_core_03
# 需要导入模块: from coapthon.messages.request import Request [as 别名]
# 或者: from coapthon.messages.request.Request import accept [as 别名]
def test_td_coap_core_03(self):
print "TD_COAP_CORE_03"
path = "/test"
req = Request()
req.code = defines.Codes.PUT.number
req.uri_path = path
req.type = defines.Types["CON"]
req.content_type = defines.Content_types["application/xml"]
req._mid = self.current_mid
req.destination = self.server_address
req.payload = "<value>test</value>"
expected = Response()
expected.type = defines.Types["ACK"]
expected._mid = self.current_mid
expected.code = defines.Codes.CHANGED.number
expected.token = None
expected.payload = None
self.current_mid += 1
exchange1 = (req, expected)
req = Request()
req.code = defines.Codes.GET.number
req.uri_path = path
req.type = defines.Types["CON"]
req._mid = self.current_mid
req.destination = self.server_address
expected = Response()
expected.type = defines.Types["ACK"]
expected._mid = self.current_mid
expected.code = defines.Codes.CONTENT.number
expected.token = None
expected.payload = "<value>test</value>"
expected.content_type = defines.Content_types["application/xml"]
self.current_mid += 1
exchange2 = (req, expected)
req = Request()
req.code = defines.Codes.GET.number
req.uri_path = path
req.type = defines.Types["CON"]
req._mid = self.current_mid
req.destination = self.server_address
req.accept = defines.Content_types["application/xml"]
expected = Response()
expected.type = defines.Types["ACK"]
expected._mid = self.current_mid
expected.code = defines.Codes.CONTENT.number
expected.token = None
expected.payload = "<value>test</value>"
expected.content_type = defines.Content_types["application/xml"]
self.current_mid += 1
exchange3 = (req, expected)
self._test_with_client([exchange1, exchange2, exchange3])