Exemplo n.º 1
0
 def _check_setup(self, cons_dir):
     inst = SibraExtSteady()
     inst._get_prev_raw = create_mock()
     inst.setup = True
     inst.path_ids = "path ids"
     iof = create_mock(["cons_dir_flag"])
     iof.cons_dir_flag = cons_dir
     hof = create_mock(["egress_if", "ingress_if"])
     path = create_mock(["get_hof", "get_iof"])
     path.get_iof.return_value = iof
     path.get_hof.return_value = hof
     spkt = create_mock(["path"])
     spkt.path = path
     req = create_mock(["add_hop"])
     inst.req_block = req
     # Call
     inst._add_hop("key", spkt)
     # Tests
     if cons_dir:
         req.add_hop.assert_called_once_with(
             hof.ingress_if, hof.egress_if, inst._get_prev_raw.return_value,
             "key", "path ids")
     else:
         req.add_hop.assert_called_once_with(
             hof.egress_if, hof.ingress_if, inst._get_prev_raw.return_value,
             "key", "path ids")
Exemplo n.º 2
0
 def test_non_setup(self, super_addhop):
     inst = SibraExtSteady()
     inst.setup = False
     # Call
     inst._add_hop("key")
     # Tests
     super_addhop.assert_called_once_with(inst, "key")
Exemplo n.º 3
0
 def test(self):
     inst = SibraExtSteady()
     inst._parse_start = create_mock()
     inst._parse_start.return_value = "data", "req"
     inst._parse_path_id = create_mock()
     inst._parse_block = create_mock()
     inst._parse_end = create_mock()
     inst.path_lens = [5, 0, 0]
     # Call
     inst._parse("raw")
     # Tests
     inst._parse_start.assert_called_once_with("raw")
     inst._parse_path_id.assert_called_once_with("data")
     ntools.eq_(inst.path_ids, [inst._parse_path_id.return_value])
     inst._parse_block.assert_called_once_with("data", 5)
     ntools.eq_(inst.active_blocks, [inst._parse_block.return_value])
     inst._parse_end.assert_called_once_with("data", "req")
Exemplo n.º 4
0
def parse_sibra_ext(raw):  # pragma: no cover
    flag = raw[0]
    if flag & FLAG_STEADY:
        return SibraExtSteady(raw)
    else:
        return SibraExtEphemeral(raw)