def test_empty(self): inst = SCIONPath() inst._ofs = [] # Call inst._init_of_idxs() # Tests ntools.eq_(inst._iof_idx, 0) ntools.eq_(inst._hof_idx, 0)
def test_non_peer(self): inst = SCIONPath() inst._ofs = [1] iof = create_mock(["peer"]) iof.peer = False inst.get_iof = create_mock() inst.get_iof.return_value = iof inst.inc_hof_idx = create_mock() # Call inst._init_of_idxs() # Tests ntools.eq_(inst._iof_idx, 0) ntools.eq_(inst._hof_idx, 0) inst.inc_hof_idx.assert_called_once_with()
def test_full(self, raw): inst = SCIONPath() inst._parse_iof = create_mock() inst._parse_hofs = create_mock() inst._init_of_idxs = create_mock() iof_list = [] for i in 2, 4, 6: iof = create_mock(["hops", "shortcut"]) iof.hops = i iof.shortcut = False iof_list.append(iof) inst._parse_iof.side_effect = iof_list data = create_mock() data.side_effect = ("A IOF", "A HOFS", "B IOF", "B HOFS", "C IOF", "C HOFS") raw.return_value = data # Call inst._parse("data") # Tests assert_these_calls(inst._parse_iof, [ call(data, inst.A_IOF), call(data, inst.B_IOF), call(data, inst.C_IOF) ]) assert_these_calls(inst._parse_hofs, [ call(data, inst.A_HOFS, 2), call(data, inst.B_HOFS, 4), call(data, inst.C_HOFS, 6) ]) inst._init_of_idxs.assert_called_once_with()
def _check_peer(self, xover, expected): inst = SCIONPath() inst._ofs = create_mock(["__len__", "get_by_idx"]) iof = create_mock(["peer"]) inst.get_iof = create_mock() inst.get_iof.return_value = iof hof = create_mock(["xover"]) hof.xover = xover inst._ofs.get_by_idx.return_value = hof inst.inc_hof_idx = create_mock() # Call inst._init_of_idxs() # Tests inst._ofs.get_by_idx.assert_called_once_with(1) ntools.eq_(inst._iof_idx, 0) ntools.eq_(inst._hof_idx, expected)