Exemple #1
0
 def test_key_in_range_handles_string(self):
     """
     Ensures the keyInRange method decodes a string representation of a key
     correctly, before testing if it's within range.
     """
     bucket = KBucket(1, 66)
     self.assertTrue(bucket.key_in_range('A'))
Exemple #2
0
 def test_key_in_range_no_too_low(self):
     """
     Ensures a key just below the k-bucket's range is identified as out of
     range.
     """
     bucket = KBucket(5, 9)
     self.assertFalse(bucket.key_in_range(2))
Exemple #3
0
 def test_key_in_range_no_too_high(self):
     """
     Ensures a key just above the k-bucket's range is identified as out of
     range.
     """
     bucket = KBucket(1, 5)
     self.assertFalse(bucket.key_in_range(7))
Exemple #4
0
 def test_key_in_range_yes(self):
     """
     Ensures that a key within the appropriate range is identified as such.
     """
     bucket = KBucket(1, 9)
     self.assertTrue(bucket.key_in_range(2))