def test_construct_weight(self): data_dict = {"9": 10, "1": []} segment_list = dict([(int(l), r) for (l, r) in data_dict.items()]) weight_hex = b'\x09\x06\x00\x00\x00\x00\x00\x0a' sid_hex = b'' self.assertEqual((weight_hex, sid_hex), TunnelEncaps.construct_weight_and_seg(segment_list))
def test_construct_seg(self): data_dict = { "1": [{ "1": { "label": 2000 } }, { "3": { "node": "10.1.1.1", "SID": { "label": 2000, "TC": 0, "S": 0, "TTL": 255 } } }] } segment_list = dict([(int(l), r) for (l, r) in data_dict.items()]) weight_hex = b'' sid_hex = b'\x01\x06\x00\x00\x00\x7d\x00\xff\x03\x0a\x00\x00\x0a\x01\x01\x01\x00\x7d\x00\xff' self.assertEqual((weight_hex, sid_hex), TunnelEncaps.construct_weight_and_seg(segment_list))