def test(self): inst = PathStore(create_mock_full({'history_limit': 3})) numCandidates = 5 pathLength = 5 inst.candidates = [] inst.disjointness = {} for i in range(numCandidates): id_ = i * (2 * pathLength + 1) asms = [] for j in range(pathLength): isdas = 9, id_ + j + 1 hof = create_mock_full({'egress_if': isdas[1] + pathLength}) pcbm = create_mock_full({'hof()': hof}) asms.append( create_mock_full({ "isd_as()": isdas, "pcbm()": pcbm })) inst.disjointness[isdas[1]] = 1.0 inst.disjointness[hof.egress_if] = 1.0 pcb = create_mock_full({"iter_asms()": asms}) record = create_mock_full({ 'pcb': pcb, 'disjointness': 0, 'id': id_ }) inst.disjointness[id_] = 1.0 inst.candidates.append(record) inst._update_disjointness_db = create_mock() inst._update_all_disjointness() for i in range(numCandidates): ntools.assert_almost_equal(inst.candidates[i].disjointness, 1.0)
def test_basic(self): path_policy = MagicMock(spec_set=['history_limit']) path_policy.history_limit = 3 pth_str = PathStore(path_policy) pth_str._update_all_disjointness = MagicMock(spec_set=[]) pth_str._update_all_delay_time = MagicMock(spec_set=[]) pth_str.candidates = [MagicMock(spec_set=['update_fidelity']) for i in range(5)] pth_str._update_all_fidelity() pth_str._update_all_disjointness.assert_called_once_with() pth_str._update_all_delay_time.assert_called_once_with() for i in range(5): pth_str.candidates[i].update_fidelity.assert_called_once_with( path_policy)