Beispiel #1
0
 def test(self, init, get_time):
     inst = PathStoreRecord("pcb")
     get_time.return_value = 100
     pcb = create_mock(
         ["copy", "get_hops_hash", "get_timestamp", "get_expiration_time"])
     inst.id = pcb.get_hops_hash.return_value
     pcb.get_timestamp.return_value = 95
     # Call
     inst.update(pcb)
     # Tests
     pcb.copy.assert_called_once_with()
     ntools.eq_(inst.delay_time, 5)
     ntools.eq_(inst.last_seen_time, 100)
     ntools.eq_(inst.expiration_time, pcb.get_expiration_time.return_value)
Beispiel #2
0
 def test(self, get_time, update):
     pcb = create_mock(['get_hops_hash', 'get_n_hops', 'get_n_peer_links'],
                       class_=PathSegment)
     get_time.return_value = PathStoreRecord.DEFAULT_OFFSET + 1
     # Call
     inst = PathStoreRecord(pcb)
     # Tests
     ntools.eq_(inst.id, pcb.get_hops_hash.return_value)
     ntools.eq_(inst.peer_links, pcb.get_n_peer_links.return_value)
     ntools.eq_(inst.hops_length, pcb.get_n_hops.return_value)
     ntools.eq_(inst.fidelity, 0)
     ntools.eq_(inst.disjointness, 0)
     ntools.eq_(inst.last_sent_time, 1)
     ntools.eq_(inst.guaranteed_bandwidth, 0)
     ntools.eq_(inst.available_bandwidth, 0)
     ntools.eq_(inst.total_bandwidth, 0)
     update.assert_called_once_with(inst, pcb)
Beispiel #3
0
 def test_basic(self, init, time_):
     path_policy = PathPolicy()
     path_policy.property_weights['PeerLinks'] = 10
     path_policy.property_weights['HopsLength'] = 1
     path_policy.property_weights['Disjointness'] = 2
     path_policy.property_weights['LastSentTime'] = 3
     path_policy.property_weights['LastSeenTime'] = 4
     path_policy.property_weights['DelayTime'] = 5
     path_policy.property_weights['ExpirationTime'] = 6
     path_policy.property_weights['GuaranteedBandwidth'] = 7
     path_policy.property_weights['AvailableBandwidth'] = 8
     path_policy.property_weights['TotalBandwidth'] = 9
     pth_str_rec = PathStoreRecord("pcb")
     pth_str_rec.peer_links = 10**5
     pth_str_rec.hops_length = (1 / (10**4))
     pth_str_rec.disjointness = 10**3
     pth_str_rec.last_sent_time = -99
     pth_str_rec.last_seen_time = 10
     pth_str_rec.delay_time = 1
     pth_str_rec.expiration_time = 10 / 9
     pth_str_rec.guaranteed_bandwidth = 10**-2
     pth_str_rec.available_bandwidth = 10**-3
     pth_str_rec.total_bandwidth = 10**-4
     time_.return_value = 1
     pth_str_rec.update_fidelity(path_policy)
     ntools.assert_almost_equal(pth_str_rec.fidelity, 1012345.6789)