mirror of
https://github.com/espressif/openthread.git
synced 2026-11-09 07:50:55 +00:00
[tests] add test case Cert_9_2_02 (#3589)
1. Add new test case **Cert_9_2_02**. Since the test case contains 2 topologies, added 2 new files: - `Cert_9_2_02A_MGMTCommissionerSet.py`, - `Cert_9_2_02B_MGMTCommissionerSet.py`. 2. Add mesh_cop tlvs parsing. The corresponding file is `mesh_cop.py`. The mesh_cop tlvs are used in many cases. For example, `CommissionerSessionId` is used in both the parsing of **Commissioning Data**(in mle) and the parsing of **CoAP**. Collected all mesh_cop tlvs refered in Thread into this file with some unused tlvs unimplemented. 3. Reuse `SubTlvsFactory` in `network_data.py`. `SubTlvsFactory` are used to choose the corresponding factory of specific tlv and do the parsing of it. The `NetworkLayerTlvsFactory` in `network_layer.py` had exactly the same function with it (almost the same code). Moved the `SubTlvsFactory` into a new file `tlvs_parsing.py` and change the usage in `network_data.py` and `network_layer.py`. This helps us remove some redundant code. 4. Some format issues. Remove some trailing spaces.
This commit is contained in:
@@ -481,24 +481,5 @@ class TestThreadNetworkDataFactory(unittest.TestCase):
|
||||
self.assertEqual(tlvs, thread_network_data.tlvs)
|
||||
|
||||
|
||||
class TestNetworkLayerTlvsFactory(unittest.TestCase):
|
||||
|
||||
def test_should_create_tlv_when_parse_method_is_called(self):
|
||||
# GIVEN
|
||||
class DummyNetworkDataTlvsFactory:
|
||||
|
||||
def parse(self, data, message_info):
|
||||
return bytearray(data.read())
|
||||
|
||||
tlv = any_tlv_data()
|
||||
|
||||
factory = network_layer.NetworkLayerTlvsFactory({tlv[0]: DummyNetworkDataTlvsFactory()})
|
||||
|
||||
# WHEN
|
||||
actual_tlvs = factory.parse(io.BytesIO(tlv), None)
|
||||
|
||||
# THEN
|
||||
self.assertEqual(tlv[2:], actual_tlvs[0])
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user