Beispiel #1
0
 def test_rfb_basic_export(self):
     ''' basic rotating Bloom Filter export test '''
     blm = RotatingBloomFilter(est_elements=25, false_positive_rate=0.05)
     blm.export('test.rbf')
     self.assertEqual(calc_file_md5('test.rbf'),
                      'eb5769ae9babdf7b37d6ce64d58812bc')
     os.remove('test.rbf')
 def test_rfb_basic_export(self):
     """ basic rotating Bloom Filter export test """
     blm = RotatingBloomFilter(est_elements=25, false_positive_rate=0.05)
     blm.export("test.rbf")
     self.assertEqual(calc_file_md5("test.rbf"),
                      "eb5769ae9babdf7b37d6ce64d58812bc")
     os.remove("test.rbf")
Beispiel #3
0
    def test_rbf_import_empty(self):
        """test that rotating Bloom Filter is correct on import"""
        with NamedTemporaryFile(dir=os.getcwd(), suffix=".rbf", delete=DELETE_TEMP_FILES) as fobj:
            blm = RotatingBloomFilter(est_elements=25, false_positive_rate=0.05)
            blm.export(fobj.name)
            self.assertEqual(calc_file_md5(fobj.name), "eb5769ae9babdf7b37d6ce64d58812bc")

            blm2 = ExpandingBloomFilter(filepath=fobj.name)
            for bloom in blm2._blooms:
                self.assertEqual(bloom.elements_added, 0)
    def test_rbf_import_empty(self):
        ''' test that rotating Bloom Filter is correct on import '''
        blm = RotatingBloomFilter(est_elements=25, false_positive_rate=0.05)
        blm.export('test.rbf')
        self.assertEqual(calc_file_md5('test.rbf'), '1581beab91f83b7e5aaf0f059ee94eaf')

        blm2 = ExpandingBloomFilter(filepath='test.rbf')
        for bloom in blm2._blooms:
            self.assertEqual(bloom.elements_added, 0)

        os.remove('test.rbf')
Beispiel #5
0
    def test_rbf_import_empty(self):
        ''' test that rotating Bloom Filter is correct on import '''
        blm = RotatingBloomFilter(est_elements=25, false_positive_rate=0.05)
        blm.export('test.rbf')
        self.assertEqual(calc_file_md5('test.rbf'),
                         'eb5769ae9babdf7b37d6ce64d58812bc')

        blm2 = ExpandingBloomFilter(filepath='test.rbf')
        for bloom in blm2._blooms:
            self.assertEqual(bloom.elements_added, 0)

        os.remove('test.rbf')
Beispiel #6
0
    def test_rbf_non_basic_import(self):
        ''' test that the imported rotating Bloom filter is correct '''
        blm = RotatingBloomFilter(est_elements=25, false_positive_rate=0.05)
        for i in range(15):
            blm.add('{}'.format(i))
            blm.push()
        blm.export('test.rbf')

        blm2 = RotatingBloomFilter(filepath='test.rbf')
        # test those that should be popped off...
        for i in range(5):
            self.assertEqual('{}'.format(i) in blm2, False)
        # test things that would not be popped
        for i in range(6, 15):
            self.assertEqual('{}'.format(i) in blm2, True)
        self.assertEqual(blm2.current_queue_size, 10)
        self.assertEqual(blm2.expansions, 9)
        os.remove('test.rbf')
    def test_rbf_non_basic_import(self):
        ''' test that the imported rotating Bloom filter is correct '''
        blm = RotatingBloomFilter(est_elements=25, false_positive_rate=0.05)
        for i in range(15):
            blm.add('{}'.format(i))
            blm.push()
        blm.export('test.rbf')

        blm2 = RotatingBloomFilter(filepath='test.rbf')
        # test those that should be popped off...
        for i in range(5):
            self.assertEqual('{}'.format(i) in blm2, False)
        # test things that would not be popped
        for i in range(6, 15):
            self.assertEqual('{}'.format(i) in blm2, True)
        self.assertEqual(blm2.current_queue_size, 10)
        self.assertEqual(blm2.expansions, 9)
        os.remove('test.rbf')
Beispiel #8
0
    def test_rbf_non_basic_import(self):
        """test that the imported rotating Bloom filter is correct"""
        with NamedTemporaryFile(dir=os.getcwd(), suffix=".rbf", delete=DELETE_TEMP_FILES) as fobj:
            blm = RotatingBloomFilter(est_elements=25, false_positive_rate=0.05)
            for i in range(15):
                blm.add("{}".format(i))
                blm.push()
            blm.export(fobj.name)

            blm2 = RotatingBloomFilter(filepath=fobj.name)
            # test those that should be popped off...
            for i in range(5):
                self.assertEqual("{}".format(i) in blm2, False)
            # test things that would not be popped
            for i in range(6, 15):
                self.assertEqual("{}".format(i) in blm2, True)
            self.assertEqual(blm2.current_queue_size, 10)
            self.assertEqual(blm2.expansions, 9)
            self.assertEqual(blm2.elements_added, 15)
Beispiel #9
0
 def test_rfb_basic_export(self):
     """basic rotating Bloom Filter export test"""
     with NamedTemporaryFile(dir=os.getcwd(), suffix=".rbf", delete=DELETE_TEMP_FILES) as fobj:
         blm = RotatingBloomFilter(est_elements=25, false_positive_rate=0.05)
         blm.export(fobj.name)
         self.assertEqual(calc_file_md5(fobj.name), "eb5769ae9babdf7b37d6ce64d58812bc")
 def test_rfb_basic_export(self):
     ''' basic rotating Bloom Filter export test '''
     blm = RotatingBloomFilter(est_elements=25, false_positive_rate=0.05)
     blm.export('test.rbf')
     self.assertEqual(calc_file_md5('test.rbf'), '1581beab91f83b7e5aaf0f059ee94eaf')
     os.remove('test.rbf')