Example #1
0
 def test_eq_nonequal(self):
     bucket1 = tables.Bucket(slots=10)
     bucket2 = tables.Bucket(slots=10)
     for i in range(5):
         bucket1[i] = tables.PeerEntry(i)
         bucket2[i] = tables.PeerEntry(-i)
     self.assertNotEqual(bucket1, bucket2)
Example #2
0
 def test_eq_nonequal(self):
     table1 = tables.BaseTable(10, 10)
     table2 = tables.BaseTable(10, 10)
     for i in range(5):
         for j in range(10):
             table1[i][j] = tables.PeerEntry(i * j)
             table2[i][j] = tables.PeerEntry(i + j)
     self.assertNotEqual(table1, table2)
Example #3
0
 def test_clear(self):
     bucket = tables.Bucket(slots=10)
     for i in range(10):
         bucket[i] = tables.PeerEntry(0)
     bucket.clear()
     for i in range(10):
         self.assertEqual(bucket[i], None)
     self.assertEqual(len(bucket), 0)
Example #4
0
 def test_delitem_nonempty(self):
     table = tables.BaseTable(1, 1)
     table[0][0] = tables.PeerEntry(0)
     del table[0]
     self.assertEqual(table[0], tables.Bucket(slots=1))
     self.assertEqual(len(table), 0)
Example #5
0
 def test_get_item(self):
     table = tables.BaseTable(1, 1)
     table[0][0] = tables.PeerEntry(0)
     self.assertEqual(table[0], table.elems[0])
Example #6
0
 def test_eq_entry(self):
     self.assertEqual(tables.PeerEntry(0, timestamp=1),
                      tables.PeerEntry(0, timestamp=1))
Example #7
0
 def test_le_entry(self):
     self.assertLessEqual(tables.PeerEntry(0, timestamp=1),
                          tables.PeerEntry(1, timestamp=1))
Example #8
0
 def test_setitem_entry_none(self):
     n = node.Node(outpeers=8)
     n[0] = tables.PeerEntry(0)
     n[0] = None
     self.assertEqual(n[0], None)
     self.assertEqual(len(n), 0)
Example #9
0
 def test_getitem_entry(self):
     n = node.Node(outpeers=8)
     e = tables.PeerEntry(0)
     n[0] = e
     self.assertEqual(n[0], e)
Example #10
0
 def test_property_ip(self):
     self.assertEqual(tables.PeerEntry(0).ip, 0)
Example #11
0
 def test_default_timestamp(self):
     self.assertEqual(tables.PeerEntry(0).timestamp, None)
Example #12
0
 def test_del_item_entry(self):
     bucket = tables.Bucket(slots=1)
     bucket[0] = tables.PeerEntry(0)
     del bucket[0]
     self.assertEqual(bucket[0], None)
     self.assertEqual(len(bucket), 0)
Example #13
0
 def test_set_item_entry_to_none(self):
     bucket = tables.Bucket(slots=1)
     bucket[0] = tables.PeerEntry(0)
     bucket[0] = None
     self.assertEqual(bucket[0], None)
     self.assertEqual(len(bucket), 0)
Example #14
0
 def test_set_item_none_to_entry(self):
     bucket = tables.Bucket(slots=1)
     entry = tables.PeerEntry(0)
     bucket[0] = entry
     self.assertEqual(bucket[0], entry)
     self.assertEqual(len(bucket), 1)
Example #15
0
 def test_getitem_entry(self):
     bucket = tables.Bucket(slots=2)
     bucket[0] = tables.PeerEntry(0)
     self.assertEqual(bucket[0], bucket.elems[0])
Example #16
0
 def test_property_timestamp(self):
     self.assertEqual(tables.PeerEntry(0, timestamp=1).timestamp, 1)
Example #17
0
 def test_nonzero_len(self):
     n = node.Node(outpeers=8)
     for i in range(5):
         n[i] = tables.PeerEntry(0)
     self.assertEqual(len(n), 5)
Example #18
0
 def test_lt_entry(self):
     self.assertLess(tables.PeerEntry(0, timestamp=1),
                     tables.PeerEntry(1, timestamp=2))
Example #19
0
 def test_setitem_none_entry(self):
     n = node.Node(outpeers=8)
     e = tables.PeerEntry(0)
     n[0] = e
     self.assertEqual(n[0], e)
     self.assertEqual(len(n), 1)
Example #20
0
 def test_nonzero_len(self):
     table = tables.BaseTable(buckets=10, slots=10)
     for i in range(5):
         for j in range(5):
             table[i][j] = tables.PeerEntry(0)
     self.assertEqual(len(table), 25)
Example #21
0
 def test_delitem_entry(self):
     n = node.Node(outpeers=8)
     n[0] = tables.PeerEntry(0)
     del n[0]
     self.assertEqual(n[0], None)
     self.assertEqual(len(n), 0)
Example #22
0
 def test_nonzero_len(self):
     bucket = tables.Bucket(slots=10)
     for i in range(5):
         bucket[i] = tables.PeerEntry(0)
     self.assertEqual(len(bucket), 5)