Example #1
0
 def test_bf_intersec_invalid_msg(self):
     """ check invalid type in a intersection message """
     msg = "The parameter second must be of type BloomFilter or " "a BloomFilterOnDisk"
     blm = BloomFilter(est_elements=10, false_positive_rate=0.05)
     blm.add("this is a test")
     try:
         blm.intersection(1)
     except TypeError as ex:
         self.assertEqual(str(ex), msg)
     else:
         self.assertEqual(True, False)
Example #2
0
 def test_bf_intersec_invalid_msg(self):
     ''' check invalid type in a intersection message '''
     msg = ('The parameter second must be of type BloomFilter or '
            'a BloomFilterOnDisk')
     blm = BloomFilter(est_elements=10, false_positive_rate=0.05)
     blm.add('this is a test')
     try:
         blm.intersection(1)
     except TypeError as ex:
         self.assertEqual(str(ex), msg)
     else:
         self.assertEqual(True, False)
Example #3
0
    def test_bf_intersection_diff(self):
        """make sure checking for different bloom filters works intersection"""
        blm = BloomFilter(est_elements=10, false_positive_rate=0.05)
        blm.add("this is a test")
        blm2 = BloomFilter(est_elements=100, false_positive_rate=0.05)

        blm3 = blm.intersection(blm2)
        self.assertEqual(blm3, None)
Example #4
0
    def test_bf_intersection_diff(self):
        ''' make sure checking for different bloom filters works
            intersection '''
        blm = BloomFilter(est_elements=10, false_positive_rate=0.05)
        blm.add('this is a test')
        blm2 = BloomFilter(est_elements=100, false_positive_rate=0.05)

        blm3 = blm.intersection(blm2)
        self.assertEqual(blm3, None)
Example #5
0
    def test_bf_intersection(self):
        """ test the union of two bloom filters """
        blm = BloomFilter(est_elements=10, false_positive_rate=0.05)
        blm.add("this is a test")
        blm.add("this is another test")
        blm2 = BloomFilter(est_elements=10, false_positive_rate=0.05)
        blm2.add("this is another test")
        blm2.add("this is yet another test")

        blm3 = blm.intersection(blm2)
        self.assertEqual(blm3.estimate_elements(), 1)
        self.assertEqual(blm3.elements_added, 1)
        self.assertEqual(blm3.check("this is a test"), False)
        self.assertEqual(blm3.check("this is another test"), True)
        self.assertEqual(blm3.check("this is yet another test"), False)
        self.assertEqual(blm3.check("this is not another test"), False)
Example #6
0
    def test_bf_intersection(self):
        ''' test the union of two bloom filters '''
        blm = BloomFilter(est_elements=10, false_positive_rate=0.05)
        blm.add('this is a test')
        blm.add('this is another test')
        blm2 = BloomFilter(est_elements=10, false_positive_rate=0.05)
        blm2.add('this is another test')
        blm2.add('this is yet another test')

        blm3 = blm.intersection(blm2)
        self.assertEqual(blm3.estimate_elements(), 1)
        self.assertEqual(blm3.elements_added, 1)
        self.assertEqual(blm3.check('this is a test'), False)
        self.assertEqual(blm3.check('this is another test'), True)
        self.assertEqual(blm3.check('this is yet another test'), False)
        self.assertEqual(blm3.check('this is not another test'), False)