mirror of
https://github.com/espressif/openthread.git
synced 2026-07-27 06:17:47 +00:00
[style] change python yapf column_limit to 119 (#5339)
This commit is contained in:
@@ -58,9 +58,8 @@ def convert_border_router_to_bytearray(border_router):
|
||||
data = struct.pack(
|
||||
">HBB",
|
||||
border_router.border_router_16,
|
||||
(border_router.o & 0x01) | ((border_router.r & 0x01) << 1) |
|
||||
((border_router.c & 0x01) << 2) | ((border_router.d & 0x01) << 3) |
|
||||
((border_router.s & 0x01) << 4) | ((border_router.p & 0x01) << 5) |
|
||||
(border_router.o & 0x01) | ((border_router.r & 0x01) << 1) | ((border_router.c & 0x01) << 2) |
|
||||
((border_router.d & 0x01) << 3) | ((border_router.s & 0x01) << 4) | ((border_router.p & 0x01) << 5) |
|
||||
((border_router.prf & 0x03) << 6),
|
||||
((border_router.n & 0x01) << 7),
|
||||
)
|
||||
@@ -69,8 +68,7 @@ def convert_border_router_to_bytearray(border_router):
|
||||
|
||||
|
||||
def convert_lowpan_id_to_bytearray(lowpan_id):
|
||||
return bytearray(
|
||||
[lowpan_id.cid | (lowpan_id.c << 4), lowpan_id.context_length])
|
||||
return bytearray([lowpan_id.cid | (lowpan_id.c << 4), lowpan_id.context_length])
|
||||
|
||||
|
||||
def convert_prefix_sub_tlvs_to_bytearray(sub_tlvs):
|
||||
@@ -123,8 +121,7 @@ def convert_service_to_bytearray(service):
|
||||
((service.t & 0x01) << 7) | ((service.id) & 0x0F),
|
||||
service.enterprise_number,
|
||||
service.service_data_length,
|
||||
) + service.service_data +
|
||||
convert_service_sub_tlvs_to_bytearray(service.sub_tlvs))
|
||||
) + service.service_data + convert_service_sub_tlvs_to_bytearray(service.sub_tlvs))
|
||||
|
||||
|
||||
def any_border_router_16():
|
||||
@@ -162,9 +159,7 @@ def any_prefix(prefix_length=None):
|
||||
if prefix_length is None:
|
||||
prefix_length = any_prefix_length()
|
||||
|
||||
return bytearray([
|
||||
random.getrandbits(8) for _ in range(int(math.ceil(prefix_length / 8)))
|
||||
])
|
||||
return bytearray([random.getrandbits(8) for _ in range(int(math.ceil(prefix_length / 8)))])
|
||||
|
||||
|
||||
def any_p():
|
||||
@@ -219,8 +214,7 @@ def any_border_router():
|
||||
|
||||
|
||||
def any_lowpan_id():
|
||||
return network_data.LowpanId(any_c(), any_cid(), any_context_length(),
|
||||
any_stable())
|
||||
return network_data.LowpanId(any_c(), any_cid(), any_context_length(), any_stable())
|
||||
|
||||
|
||||
def any_prefix_sub_tlvs():
|
||||
@@ -291,8 +285,7 @@ def any_stable():
|
||||
|
||||
class TestRoute(unittest.TestCase):
|
||||
|
||||
def test_should_return_border_router_16_value_when_border_router_16_property_is_called(
|
||||
self):
|
||||
def test_should_return_border_router_16_value_when_border_router_16_property_is_called(self):
|
||||
# GIVEN
|
||||
border_router_16 = any_border_router_16()
|
||||
|
||||
@@ -319,16 +312,14 @@ class TestRoute(unittest.TestCase):
|
||||
|
||||
class TestRouteFactory(unittest.TestCase):
|
||||
|
||||
def test_should_create_Route_from_bytearray_when_parse_method_is_called(
|
||||
self):
|
||||
def test_should_create_Route_from_bytearray_when_parse_method_is_called(self):
|
||||
# GIVEN
|
||||
border_router_16 = any_border_router_16()
|
||||
prf = any_prf()
|
||||
|
||||
factory = network_data.RouteFactory()
|
||||
|
||||
data = convert_route_to_bytearray(
|
||||
network_data.Route(border_router_16, prf))
|
||||
data = convert_route_to_bytearray(network_data.Route(border_router_16, prf))
|
||||
|
||||
# WHEN
|
||||
actual_route = factory.parse(io.BytesIO(data), None)
|
||||
@@ -341,8 +332,7 @@ class TestRouteFactory(unittest.TestCase):
|
||||
|
||||
class TestRoutesFactory(unittest.TestCase):
|
||||
|
||||
def test_should_create_Route_list_from_bytearray_when_parse_method_is_called(
|
||||
self):
|
||||
def test_should_create_Route_list_from_bytearray_when_parse_method_is_called(self):
|
||||
# GIVEN
|
||||
routes = any_routes()
|
||||
|
||||
@@ -386,14 +376,12 @@ class TestHasRoute(unittest.TestCase):
|
||||
|
||||
class TestHasRouteFactory(unittest.TestCase):
|
||||
|
||||
def test_should_create_HasRoute_from_bytearray_when_parse_method_is_called(
|
||||
self):
|
||||
def test_should_create_HasRoute_from_bytearray_when_parse_method_is_called(self):
|
||||
# GIVEN
|
||||
routes = any_routes()
|
||||
stable = any_stable()
|
||||
|
||||
factory = network_data.HasRouteFactory(
|
||||
network_data.RoutesFactory(network_data.RouteFactory()))
|
||||
factory = network_data.HasRouteFactory(network_data.RoutesFactory(network_data.RouteFactory()))
|
||||
|
||||
data = convert_routes_to_bytearray(routes)
|
||||
|
||||
@@ -411,8 +399,7 @@ class TestHasRouteFactory(unittest.TestCase):
|
||||
|
||||
class TestPrefix(unittest.TestCase):
|
||||
|
||||
def test_should_return_domain_id_value_when_domain_id_property_is_called(
|
||||
self):
|
||||
def test_should_return_domain_id_value_when_domain_id_property_is_called(self):
|
||||
# GIVEN
|
||||
domain_id = any_domain_id()
|
||||
|
||||
@@ -430,8 +417,7 @@ class TestPrefix(unittest.TestCase):
|
||||
# THEN
|
||||
self.assertEqual(domain_id, actual_domain_id)
|
||||
|
||||
def test_should_return_prefix_length_value_when_prefix_length_property_is_called(
|
||||
self):
|
||||
def test_should_return_prefix_length_value_when_prefix_length_property_is_called(self):
|
||||
# GIVEN
|
||||
prefix_length = any_prefix_length()
|
||||
|
||||
@@ -467,8 +453,7 @@ class TestPrefix(unittest.TestCase):
|
||||
# THEN
|
||||
self.assertEqual(prefix, actual_prefix)
|
||||
|
||||
def test_should_return_sub_tlvs_value_when_sub_tlvs_property_is_called(
|
||||
self):
|
||||
def test_should_return_sub_tlvs_value_when_sub_tlvs_property_is_called(self):
|
||||
# GIVEN
|
||||
sub_tlvs = any_prefix_sub_tlvs()
|
||||
|
||||
@@ -507,13 +492,11 @@ class TestPrefix(unittest.TestCase):
|
||||
|
||||
class TestPrefixSubTlvsFactory(unittest.TestCase):
|
||||
|
||||
def test_should_create_SubTlvs_from_bytearray_when_parse_method_is_called(
|
||||
self):
|
||||
def test_should_create_SubTlvs_from_bytearray_when_parse_method_is_called(self):
|
||||
# GIVEN
|
||||
sub_tlvs = any_prefix_sub_tlvs()
|
||||
|
||||
factory = network_data.PrefixSubTlvsFactory(
|
||||
config.create_default_network_data_prefix_sub_tlvs_factories())
|
||||
factory = network_data.PrefixSubTlvsFactory(config.create_default_network_data_prefix_sub_tlvs_factories())
|
||||
|
||||
data = convert_prefix_sub_tlvs_to_bytearray(sub_tlvs)
|
||||
|
||||
@@ -527,19 +510,16 @@ class TestPrefixSubTlvsFactory(unittest.TestCase):
|
||||
|
||||
class TestPrefixFactory(unittest.TestCase):
|
||||
|
||||
def test_should_create_Prefix_from_bytearray_when_parse_method_is_called(
|
||||
self):
|
||||
def test_should_create_Prefix_from_bytearray_when_parse_method_is_called(self):
|
||||
# GIVEN
|
||||
domain_id = any_domain_id()
|
||||
prefix_length = any_prefix_length()
|
||||
prefix = any_prefix(prefix_length)
|
||||
sub_tlvs = any_prefix_sub_tlvs()
|
||||
|
||||
factory = network_data.PrefixFactory(
|
||||
config.create_default_network_data_prefix_sub_tlvs_factory())
|
||||
factory = network_data.PrefixFactory(config.create_default_network_data_prefix_sub_tlvs_factory())
|
||||
|
||||
data = (bytearray([domain_id, prefix_length]) + prefix +
|
||||
convert_prefix_sub_tlvs_to_bytearray(sub_tlvs))
|
||||
data = (bytearray([domain_id, prefix_length]) + prefix + convert_prefix_sub_tlvs_to_bytearray(sub_tlvs))
|
||||
|
||||
message_info = common.MessageInfo()
|
||||
|
||||
@@ -556,8 +536,7 @@ class TestPrefixFactory(unittest.TestCase):
|
||||
|
||||
class TestBorderRouter(unittest.TestCase):
|
||||
|
||||
def test_should_return_border_router_16_value_when_border_router_16_property_is_called(
|
||||
self):
|
||||
def test_should_return_border_router_16_value_when_border_router_16_property_is_called(self):
|
||||
# GIVEN
|
||||
border_router_16 = any_border_router_16()
|
||||
|
||||
@@ -790,8 +769,7 @@ class TestBorderRouter(unittest.TestCase):
|
||||
|
||||
class TestBorderRouterFactory(unittest.TestCase):
|
||||
|
||||
def test_should_create_BorderRouter_from_bytearray_when_parse_method_is_called(
|
||||
self):
|
||||
def test_should_create_BorderRouter_from_bytearray_when_parse_method_is_called(self):
|
||||
# GIVEN
|
||||
border_router_16 = any_border_router_16()
|
||||
prf = any_prf()
|
||||
@@ -807,8 +785,7 @@ class TestBorderRouterFactory(unittest.TestCase):
|
||||
factory = network_data.BorderRouterFactory()
|
||||
|
||||
data = convert_border_router_to_bytearray(
|
||||
network_data.BorderRouter(border_router_16, prf, p, s, d, c, r, o,
|
||||
n, stable))
|
||||
network_data.BorderRouter(border_router_16, prf, p, s, d, c, r, o, n, stable))
|
||||
|
||||
message_info = common.MessageInfo()
|
||||
message_info.stable = stable
|
||||
@@ -817,10 +794,8 @@ class TestBorderRouterFactory(unittest.TestCase):
|
||||
actual_border_router = factory.parse(io.BytesIO(data), message_info)
|
||||
|
||||
# THEN
|
||||
self.assertTrue(
|
||||
isinstance(actual_border_router, network_data.BorderRouter))
|
||||
self.assertEqual(border_router_16,
|
||||
actual_border_router.border_router_16)
|
||||
self.assertTrue(isinstance(actual_border_router, network_data.BorderRouter))
|
||||
self.assertEqual(border_router_16, actual_border_router.border_router_16)
|
||||
self.assertEqual(prf, actual_border_router.prf)
|
||||
self.assertEqual(p, actual_border_router.p)
|
||||
self.assertEqual(s, actual_border_router.s)
|
||||
@@ -838,8 +813,7 @@ class TestLowpanId(unittest.TestCase):
|
||||
# GIVEN
|
||||
c = any_c()
|
||||
|
||||
lowpan_id = network_data.LowpanId(c, any_cid(), any_context_length(),
|
||||
any_stable())
|
||||
lowpan_id = network_data.LowpanId(c, any_cid(), any_context_length(), any_stable())
|
||||
|
||||
# WHEN
|
||||
actual_c = lowpan_id.c
|
||||
@@ -851,8 +825,7 @@ class TestLowpanId(unittest.TestCase):
|
||||
# GIVEN
|
||||
cid = any_cid()
|
||||
|
||||
lowpan_id = network_data.LowpanId(any_c(), cid, any_context_length(),
|
||||
any_stable())
|
||||
lowpan_id = network_data.LowpanId(any_c(), cid, any_context_length(), any_stable())
|
||||
|
||||
# WHEN
|
||||
actual_cid = lowpan_id.cid
|
||||
@@ -860,13 +833,11 @@ class TestLowpanId(unittest.TestCase):
|
||||
# THEN
|
||||
self.assertEqual(cid, actual_cid)
|
||||
|
||||
def test_should_return_context_length_value_when_context_length_property_is_called(
|
||||
self):
|
||||
def test_should_return_context_length_value_when_context_length_property_is_called(self):
|
||||
# GIVEN
|
||||
context_length = any_context_length()
|
||||
|
||||
lowpan_id = network_data.LowpanId(any_c(), any_cid(), context_length,
|
||||
any_stable())
|
||||
lowpan_id = network_data.LowpanId(any_c(), any_cid(), context_length, any_stable())
|
||||
|
||||
# WHEN
|
||||
actual_context_length = lowpan_id.context_length
|
||||
@@ -878,8 +849,7 @@ class TestLowpanId(unittest.TestCase):
|
||||
# GIVEN
|
||||
stable = any_stable()
|
||||
|
||||
lowpan_id = network_data.LowpanId(any_c(), any_cid(),
|
||||
any_context_length(), stable)
|
||||
lowpan_id = network_data.LowpanId(any_c(), any_cid(), any_context_length(), stable)
|
||||
|
||||
# WHEN
|
||||
actual_stable = lowpan_id.stable
|
||||
@@ -890,8 +860,7 @@ class TestLowpanId(unittest.TestCase):
|
||||
|
||||
class TestLowpanIdFactory(unittest.TestCase):
|
||||
|
||||
def test_should_create_LowpanId_from_bytearray_when_parse_method_is_called(
|
||||
self):
|
||||
def test_should_create_LowpanId_from_bytearray_when_parse_method_is_called(self):
|
||||
# GIVEN
|
||||
c = any_c()
|
||||
cid = any_cid()
|
||||
@@ -900,8 +869,7 @@ class TestLowpanIdFactory(unittest.TestCase):
|
||||
|
||||
factory = network_data.LowpanIdFactory()
|
||||
|
||||
data = convert_lowpan_id_to_bytearray(
|
||||
network_data.LowpanId(c, cid, context_length, stable))
|
||||
data = convert_lowpan_id_to_bytearray(network_data.LowpanId(c, cid, context_length, stable))
|
||||
|
||||
message_info = common.MessageInfo()
|
||||
message_info.stable = stable
|
||||
@@ -958,8 +926,7 @@ class TestService(unittest.TestCase):
|
||||
# THEN
|
||||
self.assertEqual(_id, actual_id)
|
||||
|
||||
def test_should_return_enterprise_number_value_when_enterprise_number_property_is_called(
|
||||
self):
|
||||
def test_should_return_enterprise_number_value_when_enterprise_number_property_is_called(self):
|
||||
# GIVEN
|
||||
enterprise_number = any_enterprise_number()
|
||||
|
||||
@@ -979,8 +946,7 @@ class TestService(unittest.TestCase):
|
||||
# THEN
|
||||
self.assertEqual(enterprise_number, actual_enterprise_number)
|
||||
|
||||
def test_should_return_service_data_length_value_when_service_data_length_property_is_called(
|
||||
self):
|
||||
def test_should_return_service_data_length_value_when_service_data_length_property_is_called(self):
|
||||
# GIVEN
|
||||
service_data_length = any_service_data_length()
|
||||
|
||||
@@ -1000,8 +966,7 @@ class TestService(unittest.TestCase):
|
||||
# THEN
|
||||
self.assertEqual(service_data_length, actual_service_data_length)
|
||||
|
||||
def test_should_return_service_data_value_when_service_data_property_is_called(
|
||||
self):
|
||||
def test_should_return_service_data_value_when_service_data_property_is_called(self):
|
||||
# GIVEN
|
||||
service_data = any_service_data()
|
||||
|
||||
@@ -1021,8 +986,7 @@ class TestService(unittest.TestCase):
|
||||
# THEN
|
||||
self.assertEqual(service_data, actual_service_data)
|
||||
|
||||
def test_should_return_sub_tlvs_value_when_sub_tlvs_property_is_called(
|
||||
self):
|
||||
def test_should_return_sub_tlvs_value_when_sub_tlvs_property_is_called(self):
|
||||
# GIVEN
|
||||
sub_tlvs = any_service_sub_tlvs()
|
||||
|
||||
@@ -1065,13 +1029,11 @@ class TestService(unittest.TestCase):
|
||||
|
||||
class TestServiceSubTlvsFactory(unittest.TestCase):
|
||||
|
||||
def test_should_create_SubTlvs_from_bytearray_when_parse_method_is_called(
|
||||
self):
|
||||
def test_should_create_SubTlvs_from_bytearray_when_parse_method_is_called(self):
|
||||
# GIVEN
|
||||
sub_tlvs = any_service_sub_tlvs()
|
||||
|
||||
factory = network_data.ServiceSubTlvsFactory(
|
||||
config.create_default_network_data_service_sub_tlvs_factories())
|
||||
factory = network_data.ServiceSubTlvsFactory(config.create_default_network_data_service_sub_tlvs_factories())
|
||||
|
||||
data = convert_service_sub_tlvs_to_bytearray(sub_tlvs)
|
||||
|
||||
@@ -1085,8 +1047,7 @@ class TestServiceSubTlvsFactory(unittest.TestCase):
|
||||
|
||||
class TestServiceFactory(unittest.TestCase):
|
||||
|
||||
def test_should_create_Service_from_bytearray_when_parse_method_is_called(
|
||||
self):
|
||||
def test_should_create_Service_from_bytearray_when_parse_method_is_called(self):
|
||||
# GIVEN
|
||||
t = any_t()
|
||||
_id = any_id()
|
||||
@@ -1096,8 +1057,7 @@ class TestServiceFactory(unittest.TestCase):
|
||||
sub_tlvs = any_service_sub_tlvs()
|
||||
stable = any_stable()
|
||||
|
||||
factory = network_data.ServiceFactory(
|
||||
config.create_default_network_data_service_sub_tlvs_factory())
|
||||
factory = network_data.ServiceFactory(config.create_default_network_data_service_sub_tlvs_factory())
|
||||
|
||||
data = convert_service_to_bytearray(
|
||||
network_data.Service(
|
||||
@@ -1121,16 +1081,14 @@ class TestServiceFactory(unittest.TestCase):
|
||||
self.assertEqual(t, actual_service.t)
|
||||
self.assertEqual(_id, actual_service.id)
|
||||
self.assertEqual(enterprise_number, actual_service.enterprise_number)
|
||||
self.assertEqual(service_data_length,
|
||||
actual_service.service_data_length)
|
||||
self.assertEqual(service_data_length, actual_service.service_data_length)
|
||||
self.assertEqual(service_data, actual_service.service_data)
|
||||
self.assertEqual(sub_tlvs, actual_service.sub_tlvs)
|
||||
|
||||
|
||||
class TestServer(unittest.TestCase):
|
||||
|
||||
def test_should_return_server_16_value_when_server_16_property_is_called(
|
||||
self):
|
||||
def test_should_return_server_16_value_when_server_16_property_is_called(self):
|
||||
# GIVEN
|
||||
server_16 = any_server_16()
|
||||
|
||||
@@ -1142,8 +1100,7 @@ class TestServer(unittest.TestCase):
|
||||
# THEN
|
||||
self.assertEqual(server_16, actual_server_16)
|
||||
|
||||
def test_should_return_server_data_value_when_server_data_property_is_called(
|
||||
self):
|
||||
def test_should_return_server_data_value_when_server_data_property_is_called(self):
|
||||
# GIVEN
|
||||
server_data = any_server_data()
|
||||
|
||||
@@ -1170,8 +1127,7 @@ class TestServer(unittest.TestCase):
|
||||
|
||||
class TestServerFactory(unittest.TestCase):
|
||||
|
||||
def test_should_create_Server_from_bytearray_when_parse_method_is_called(
|
||||
self):
|
||||
def test_should_create_Server_from_bytearray_when_parse_method_is_called(self):
|
||||
# GIVEN
|
||||
server_16 = any_server_16()
|
||||
server_data = any_server_data()
|
||||
@@ -1179,8 +1135,7 @@ class TestServerFactory(unittest.TestCase):
|
||||
|
||||
factory = network_data.ServerFactory()
|
||||
|
||||
data = convert_server_to_bytearray(
|
||||
network_data.Server(server_16, server_data, stable))
|
||||
data = convert_server_to_bytearray(network_data.Server(server_16, server_data, stable))
|
||||
|
||||
message_info = common.MessageInfo()
|
||||
message_info.stable = stable
|
||||
|
||||
Reference in New Issue
Block a user