[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [bridgedb/master] 5482 - Add test for bridge familiarity



commit b5d633da7aee259bd70ec744c3f713f0c21cfa18
Author: aagbsn <aagbsn@xxxxxxxx>
Date:   Mon Nov 5 13:46:10 2012 -0800

    5482 - Add test for bridge familiarity
---
 lib/bridgedb/Tests.py |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/lib/bridgedb/Tests.py b/lib/bridgedb/Tests.py
index 79638f4..238f2c3 100644
--- a/lib/bridgedb/Tests.py
+++ b/lib/bridgedb/Tests.py
@@ -696,7 +696,21 @@ class BridgeStabilityTests(unittest.TestCase):
             assert (long(last_seen*1000) == b.lastSeenWithDifferentAddressAndPort)
             assert (long(ts[-1]*1000) == b.lastSeenWithThisAddressAndPort)
 
-    # test familiar
+    def testFamiliar(self):
+        # create some bridges
+        num_bridges = 100
+        num_desc = 4*48 # 30m intervals, 48 per day
+        time_start = time.time()
+        bridges = [ fakeBridge() for x in xrange(num_bridges) ]
+        t = time.time()
+        ts = [ i*60*30+t for i in xrange(num_bridges) ]
+        for b in bridges:
+            time_series = [ 60*30*(i+1) + time_start for i in xrange(num_desc) ]
+            [ bridgedb.Stability.addOrUpdateBridgeHistory(b, i) for i in time_series ]
+        assert None not in bridges
+        # +1 to avoid rounding errors
+        assert bridges[-(num_bridges/8 + 1)].familiar == True
+
 
 def testSuite():
     suite = unittest.TestSuite()



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits