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