def test(self): inst = TracerouteExt() inst.hops = [1] inst._hdr_len = 3 # Call inst.append_hop("3-4", 5, 6) # Tests ntools.eq_(inst.hops, [1, ("3-4", 5, 6)])
def test(self, raw, super_parse, isd_as): inst = TracerouteExt() inst.append_hop = create_mock() data = create_mock(["pop"]) data.pop.side_effect = ( None, "isd as 1", bytes.fromhex('1111 2222'), "isd as 2", bytes.fromhex('3333 4444'), ) raw.return_value = data isd_as.LEN = 4 isd_as.side_effect = "1-11", "2-22" dlen = inst.MIN_LEN + 2 * inst.HOP_LEN arg = bytes([2]) + bytes(dlen - 1) # Call inst._parse(arg) # Tests raw.assert_called_once_with(arg, "TracerouteExt", dlen, min_=True) super_parse.assert_called_once_with(inst, data) assert_these_calls(isd_as, (call("isd as 1"), call("isd as 2"))) assert_these_calls(inst.append_hop, ( call("1-11", 0x1111, 0x2222), call("2-22", 0x3333, 0x4444), ))