def test_setup_new_block(self): inst = SibraExtEphemeral() inst._get_ifids = create_mock() inst._get_ifids.side_effect = ( ("prev_ingress", "prev_egress"), ("curr_ingress", "curr_egress"), ) inst._get_prev_raw = create_mock() inst.setup = True inst.block_idx = 1 inst.rel_sof_idx = 0 prev_block = create_mock(["info", "sofs"]) prev_block.info = create_mock(["fwd_dir"]) prev_block.sofs = ["prev sof0", "prev sof1"] curr_block = create_mock(["info", "sofs"]) curr_block.info = create_mock(["fwd_dir"]) curr_block.sofs = ["curr sof0", "curr sof1"] inst.active_blocks = [prev_block, curr_block] inst.req_block = create_mock(["add_hop"]) inst.path_ids = "path_ids" # Call inst._add_hop("key") # Tests assert_these_calls(inst._get_ifids, [ call("prev sof1", prev_block.info.fwd_dir), call("curr sof0", curr_block.info.fwd_dir), ]) inst.req_block.add_hop.assert_called_once_with( "prev_ingress", "curr_egress", inst._get_prev_raw.return_value, "key", "path_ids")
def test_non_setup(self, super_add_hop): inst = SibraExtEphemeral() inst.setup = False # Call inst._add_hop("key") # Tests super_add_hop.assert_called_once_with(inst, "key")
def test_setup_old_block(self): inst = SibraExtEphemeral() inst._get_ifids = create_mock() inst._get_ifids.return_value = "ingress", "egress" inst._get_prev_raw = create_mock() inst.setup = True block = create_mock(["info", "sofs"]) block.info = create_mock(["fwd_dir"]) block.sofs = ["sof0"] inst.active_blocks = [block] inst.req_block = create_mock(["add_hop"]) inst.path_ids = "path_ids" # Call inst._add_hop("key") # Tests inst._get_ifids.assert_called_once_with("sof0", block.info.fwd_dir) inst._get_prev_raw.assert_called_once_with(req=True) inst.req_block.add_hop.assert_called_once_with( "ingress", "egress", inst._get_prev_raw.return_value, "key", "path_ids")