def test_merge_filters(self): self.bloom_c = ErbBloomFilter(m=100, k=4) self.bloom_d = ErbBloomFilter(m=100, k=4) self.bloom_c.add('one') self.bloom_d.add('two') self.bloom_c = self.bloom_c.merge(self.bloom_d) self.assertTrue('one' in self.bloom_c and 'two' in self.bloom_c) self.assertTrue('one' not in self.bloom_d and 'two' in self.bloom_d)
def test_filter_removal_nodes(self): self.bloom_c = ErbBloomFilter(m=100, k=4) self.bloom_c.add('one') self.assertTrue('one' in self.bloom_c) if not FAST: #If the fast flag option is on, time doesn't pass for bloom filters self.bloom_c.pass_time() self.assertTrue('one' in self.bloom_c) self.bloom_c.pass_time() self.assertFalse('one' in self.bloom_c)
class TestERBBloom(unittest.TestCase): """ This class represents the expected behaviour to exist on a ERB bloom filter. """ def test_filter_removal_nodes(self): self.bloom_c = ErbBloomFilter(m=100, k=4) self.bloom_c.add('one') self.assertTrue('one' in self.bloom_c) if not FAST: #If the fast flag option is on, time doesn't pass for bloom filters self.bloom_c.pass_time() self.assertTrue('one' in self.bloom_c) self.bloom_c.pass_time() self.assertFalse('one' in self.bloom_c) def test_merge_filters(self): self.bloom_c = ErbBloomFilter(m=100, k=4) self.bloom_d = ErbBloomFilter(m=100, k=4) self.bloom_c.add('one') self.bloom_d.add('two') self.bloom_c = self.bloom_c.merge(self.bloom_d) self.assertTrue('one' in self.bloom_c and 'two' in self.bloom_c) self.assertTrue('one' not in self.bloom_d and 'two' in self.bloom_d)