def _check(self, up, hof_idx, expected): inst = SCIONPath() inst._iof_idx = 0 inst._hof_idx = hof_idx inst._ofs = create_mock(["get_by_idx"]) iof = create_mock(["hops", "up_flag"]) iof.hops = 5 iof.up_flag = up # Call ret = inst._get_hof_ver_normal(iof) # Tests if expected is None: ntools.eq_(ret, None) else: ntools.eq_(ret, inst._ofs.get_by_idx.return_value) inst._ofs.get_by_idx.assert_called_once_with(expected)
def _setup(self, xover=False, peer=False, shortcut=False, up_flag=True): inst = SCIONPath() inst._iof_idx = 0 inst._hof_idx = 0 iof = create_mock(["peer", "shortcut", "up_flag"]) iof.peer = peer iof.shortcut = shortcut iof.up_flag = up_flag inst.get_iof = create_mock() inst.get_iof.return_value = iof hof = create_mock(["xover"]) hof.xover = xover inst.get_hof = create_mock() inst.get_hof.return_value = hof inst._get_hof_ver_normal = create_mock() inst._ofs = create_mock(["get_by_idx"]) return inst, iof, hof