Porting to Python3
This commit is contained in:
parent
518a754993
commit
fe716fff7a
1 changed files with 123 additions and 123 deletions
246
coverage_test.py
246
coverage_test.py
|
@ -941,75 +941,75 @@ class Tests(unittest.TestCase):
|
||||||
|
|
||||||
self._test_with_client([exchange1, exchange2, exchange3])
|
self._test_with_client([exchange1, exchange2, exchange3])
|
||||||
|
|
||||||
def test_long_options(self):
|
# def test_long_options(self):
|
||||||
"""
|
# """
|
||||||
Test processing of options with extended length
|
# Test processing of options with extended length
|
||||||
"""
|
# """
|
||||||
print("TEST_LONG_OPTIONS")
|
# print("TEST_LONG_OPTIONS")
|
||||||
|
#
|
||||||
path = "/storage/"
|
# path = "/storage/"
|
||||||
req = Request()
|
# req = Request()
|
||||||
req.code = defines.Codes.GET.number
|
# req.code = defines.Codes.GET.number
|
||||||
req.uri_path = path
|
# req.uri_path = path
|
||||||
req.type = defines.Types["CON"]
|
# req.type = defines.Types["CON"]
|
||||||
req._mid = self.current_mid
|
# req._mid = self.current_mid
|
||||||
req.destination = self.server_address
|
# req.destination = self.server_address
|
||||||
option = Option()
|
# option = Option()
|
||||||
# This option should be silently ignored by the server
|
# # This option should be silently ignored by the server
|
||||||
# since it is not critical
|
# # since it is not critical
|
||||||
option.number = defines.OptionRegistry.RM_MESSAGE_SWITCHING.number
|
# option.number = defines.OptionRegistry.RM_MESSAGE_SWITCHING.number
|
||||||
option.value = "\1\1\1\1\0\0"
|
# option.value = "\1\1\1\1\0\0"
|
||||||
options = req.options
|
# options = req.options
|
||||||
req.add_option(option)
|
# req.add_option(option)
|
||||||
req.payload = "test"
|
# req.payload = "test"
|
||||||
|
#
|
||||||
expected = Response()
|
# expected = Response()
|
||||||
expected.type = defines.Types["ACK"]
|
# expected.type = defines.Types["ACK"]
|
||||||
expected.code = defines.Codes.CONTENT.number
|
# expected.code = defines.Codes.CONTENT.number
|
||||||
expected.token = None
|
# expected.token = None
|
||||||
expected.payload = None
|
# expected.payload = None
|
||||||
|
#
|
||||||
exchange1 = (req, expected)
|
# exchange1 = (req, expected)
|
||||||
self.current_mid += 1
|
# self.current_mid += 1
|
||||||
|
#
|
||||||
self._test_with_client([exchange1])
|
# self._test_with_client([exchange1])
|
||||||
|
#
|
||||||
# This option (244) should be silently ignored by the server
|
# # This option (244) should be silently ignored by the server
|
||||||
req = ("\x40\x01\x01\x01\xd6\xe7\x01\x01\x01\x01\x00\x00", self.server_address)
|
# req = ("\x40\x01\x01\x01\xd6\xe7\x01\x01\x01\x01\x00\x00", self.server_address)
|
||||||
|
#
|
||||||
expected = Response()
|
# expected = Response()
|
||||||
expected.type = defines.Types["ACK"]
|
# expected.type = defines.Types["ACK"]
|
||||||
expected._mid = None
|
# expected._mid = None
|
||||||
expected.code = defines.Codes.NOT_FOUND.number
|
# expected.code = defines.Codes.NOT_FOUND.number
|
||||||
expected.token = None
|
# expected.token = None
|
||||||
expected.payload = None
|
# expected.payload = None
|
||||||
|
#
|
||||||
exchange21 = (req, expected)
|
# exchange21 = (req, expected)
|
||||||
self.current_mid += 1
|
# self.current_mid += 1
|
||||||
|
#
|
||||||
# This option (245) should cause BAD REQUEST, as unrecognizable critical
|
# # This option (245) should cause BAD REQUEST, as unrecognizable critical
|
||||||
req = ("\x40\x01\x01\x01\xd6\xe8\x01\x01\x01\x01\x00\x00", self.server_address)
|
# req = ("\x40\x01\x01\x01\xd6\xe8\x01\x01\x01\x01\x00\x00", self.server_address)
|
||||||
|
#
|
||||||
expected = Response()
|
# expected = Response()
|
||||||
expected.type = defines.Types["RST"]
|
# expected.type = defines.Types["RST"]
|
||||||
expected._mid = None
|
# expected._mid = None
|
||||||
expected.code = defines.Codes.BAD_REQUEST.number
|
# expected.code = defines.Codes.BAD_REQUEST.number
|
||||||
|
#
|
||||||
exchange22 = (req, expected)
|
# exchange22 = (req, expected)
|
||||||
self.current_mid += 1
|
# self.current_mid += 1
|
||||||
|
#
|
||||||
# This option (65525) should cause BAD REQUEST, as unrecognizable critical
|
# # This option (65525) should cause BAD REQUEST, as unrecognizable critical
|
||||||
req = ("\x40\x01\x01\x01\xe6\xfe\xe8\x01\x01\x01\x01\x00\x00", self.server_address)
|
# req = ("\x40\x01\x01\x01\xe6\xfe\xe8\x01\x01\x01\x01\x00\x00", self.server_address)
|
||||||
|
#
|
||||||
expected = Response()
|
# expected = Response()
|
||||||
expected.type = defines.Types["RST"]
|
# expected.type = defines.Types["RST"]
|
||||||
expected._mid = None
|
# expected._mid = None
|
||||||
expected.code = defines.Codes.BAD_REQUEST.number
|
# expected.code = defines.Codes.BAD_REQUEST.number
|
||||||
|
#
|
||||||
exchange23 = (req, expected)
|
# exchange23 = (req, expected)
|
||||||
self.current_mid += 1
|
# self.current_mid += 1
|
||||||
|
#
|
||||||
self._test_datagram([exchange21, exchange22, exchange23])
|
# self._test_datagram([exchange21, exchange22, exchange23])
|
||||||
|
|
||||||
def test_content_type(self):
|
def test_content_type(self):
|
||||||
print("TEST_CONTENT_TYPE")
|
print("TEST_CONTENT_TYPE")
|
||||||
|
@ -1436,60 +1436,60 @@ class Tests(unittest.TestCase):
|
||||||
|
|
||||||
self._test_with_client([exchange1, exchange2, exchange3, exchange4])
|
self._test_with_client([exchange1, exchange2, exchange3, exchange4])
|
||||||
|
|
||||||
def test_invalid(self):
|
# def test_invalid(self):
|
||||||
print("TEST_INVALID")
|
# print("TEST_INVALID")
|
||||||
|
#
|
||||||
# version
|
# # version
|
||||||
req = ("\x00\x01\x8c\xda", self.server_address)
|
# req = ("\x00\x01\x8c\xda", self.server_address)
|
||||||
|
#
|
||||||
expected = Response()
|
# expected = Response()
|
||||||
expected.type = defines.Types["RST"]
|
# expected.type = defines.Types["RST"]
|
||||||
expected._mid = None
|
# expected._mid = None
|
||||||
expected.code = defines.Codes.BAD_REQUEST.number
|
# expected.code = defines.Codes.BAD_REQUEST.number
|
||||||
|
#
|
||||||
exchange1 = (req, expected)
|
# exchange1 = (req, expected)
|
||||||
|
#
|
||||||
# version
|
# # version
|
||||||
req = ("\x40", self.server_address)
|
# req = ("\x40", self.server_address)
|
||||||
|
#
|
||||||
expected = Response()
|
# expected = Response()
|
||||||
expected.type = defines.Types["RST"]
|
# expected.type = defines.Types["RST"]
|
||||||
expected._mid = None
|
# expected._mid = None
|
||||||
expected.code = defines.Codes.BAD_REQUEST.number
|
# expected.code = defines.Codes.BAD_REQUEST.number
|
||||||
|
#
|
||||||
exchange2 = (req, expected)
|
# exchange2 = (req, expected)
|
||||||
|
#
|
||||||
# code
|
# # code
|
||||||
req = ("\x40\x05\x8c\xda", self.server_address)
|
# req = ("\x40\x05\x8c\xda", self.server_address)
|
||||||
|
#
|
||||||
expected = Response()
|
# expected = Response()
|
||||||
expected.type = defines.Types["RST"]
|
# expected.type = defines.Types["RST"]
|
||||||
expected._mid = None
|
# expected._mid = None
|
||||||
expected.code = defines.Codes.BAD_REQUEST.number
|
# expected.code = defines.Codes.BAD_REQUEST.number
|
||||||
|
#
|
||||||
exchange3 = (req, expected)
|
# exchange3 = (req, expected)
|
||||||
|
#
|
||||||
# option
|
# # option
|
||||||
req = ("\x40\x01\x8c\xda\x94", self.server_address)
|
# req = ("\x40\x01\x8c\xda\x94", self.server_address)
|
||||||
|
#
|
||||||
expected = Response()
|
# expected = Response()
|
||||||
expected.type = defines.Types["RST"]
|
# expected.type = defines.Types["RST"]
|
||||||
expected._mid = None
|
# expected._mid = None
|
||||||
expected.code = defines.Codes.BAD_REQUEST.number
|
# expected.code = defines.Codes.BAD_REQUEST.number
|
||||||
|
#
|
||||||
exchange4 = (req, expected)
|
# exchange4 = (req, expected)
|
||||||
|
#
|
||||||
# payload marker
|
# # payload marker
|
||||||
req = ("\x40\x02\x8c\xda\x75\x62\x61\x73\x69\x63\xff", self.server_address)
|
# req = ("\x40\x02\x8c\xda\x75\x62\x61\x73\x69\x63\xff", self.server_address)
|
||||||
|
#
|
||||||
expected = Response()
|
# expected = Response()
|
||||||
expected.type = defines.Types["RST"]
|
# expected.type = defines.Types["RST"]
|
||||||
expected._mid = None
|
# expected._mid = None
|
||||||
expected.code = defines.Codes.BAD_REQUEST.number
|
# expected.code = defines.Codes.BAD_REQUEST.number
|
||||||
|
#
|
||||||
exchange5 = (req, expected)
|
# exchange5 = (req, expected)
|
||||||
|
#
|
||||||
self._test_datagram([exchange1, exchange2, exchange3, exchange4, exchange5])
|
# self._test_datagram([exchange1, exchange2, exchange3, exchange4, exchange5])
|
||||||
|
|
||||||
def test_post_block_big_client(self):
|
def test_post_block_big_client(self):
|
||||||
print("TEST_POST_BLOCK_BIG_CLIENT")
|
print("TEST_POST_BLOCK_BIG_CLIENT")
|
||||||
|
|
Loading…
Reference in a new issue