def test_ebf_export(self): ''' basic expanding Bloom Filter export test ''' blm = ExpandingBloomFilter(est_elements=25, false_positive_rate=0.05) blm.export('test.ebf') self.assertEqual(calc_file_md5('test.ebf'), 'eb5769ae9babdf7b37d6ce64d58812bc') os.remove('test.ebf')
def test_ebf_export(self): """ basic expanding Bloom Filter export test """ blm = ExpandingBloomFilter(est_elements=25, false_positive_rate=0.05) blm.export("test.ebf") self.assertEqual(calc_file_md5("test.ebf"), "eb5769ae9babdf7b37d6ce64d58812bc") os.remove("test.ebf")
def test_ebf_import_empty(self): """test that expanding Bloom Filter is correct on import""" with NamedTemporaryFile(dir=os.getcwd(), suffix=".ebf", delete=DELETE_TEMP_FILES) as fobj: blm = ExpandingBloomFilter(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_ebf_import_empty(self): ''' test that expanding Bloom Filter is correct on import ''' blm = ExpandingBloomFilter(est_elements=25, false_positive_rate=0.05) blm.export('test.ebf') self.assertEqual(calc_file_md5('test.ebf'), '1581beab91f83b7e5aaf0f059ee94eaf') blm2 = ExpandingBloomFilter(filepath='test.ebf') for bloom in blm2._blooms: self.assertEqual(bloom.elements_added, 0) os.remove('test.ebf')
def test_ebf_import_empty(self): ''' test that expanding Bloom Filter is correct on import ''' blm = ExpandingBloomFilter(est_elements=25, false_positive_rate=0.05) blm.export('test.ebf') self.assertEqual(calc_file_md5('test.ebf'), 'eb5769ae9babdf7b37d6ce64d58812bc') blm2 = ExpandingBloomFilter(filepath='test.ebf') for bloom in blm2._blooms: self.assertEqual(bloom.elements_added, 0) os.remove('test.ebf')
def test_ebf_import_non_empty(self): """test expanding Bloom Filter import when non-empty""" with NamedTemporaryFile(dir=os.getcwd(), suffix=".ebf", delete=DELETE_TEMP_FILES) as fobj: blm = ExpandingBloomFilter(est_elements=25, false_positive_rate=0.05) for i in range(15): blm.add("{}".format(i)) blm.push() blm.export(fobj.name) blm2 = ExpandingBloomFilter(filepath=fobj.name) self.assertEqual(blm2.expansions, 15) for i in range(15): self.assertEqual("{}".format(i) in blm2, True) # check for things that are not there! for i in range(99, 125): self.assertEqual("{}".format(i) in blm2, False)
def test_ebf_import_non_empty(self): ''' test expanding Bloom Filter import when non-empty ''' blm = ExpandingBloomFilter(est_elements=25, false_positive_rate=0.05) for i in range(15): blm.add('{}'.format(i)) blm.push() blm.export('test.ebf') blm2 = ExpandingBloomFilter(filepath='test.ebf') self.assertEqual(blm2.expansions, 15) for i in range(15): self.assertEqual('{}'.format(i) in blm2, True) # check for things that are not there! for i in range(99, 125): self.assertEqual('{}'.format(i) in blm2, False) os.remove('test.ebf')
def test_ebf_export(self): """basic expanding Bloom Filter export test""" with NamedTemporaryFile(dir=os.getcwd(), suffix=".ebf", delete=DELETE_TEMP_FILES) as fobj: blm = ExpandingBloomFilter(est_elements=25, false_positive_rate=0.05) blm.export(fobj.name) self.assertEqual(calc_file_md5(fobj.name), "eb5769ae9babdf7b37d6ce64d58812bc")
def test_ebf_export(self): ''' basic expanding Bloom Filter export test ''' blm = ExpandingBloomFilter(est_elements=25, false_positive_rate=0.05) blm.export('test.ebf') self.assertEqual(calc_file_md5('test.ebf'), '1581beab91f83b7e5aaf0f059ee94eaf') os.remove('test.ebf')