コード例 #1
0
def test__check_key_existence_failure():

    db_repository = BasicDBRepository()
    db_repository.data_map = {DATA_KEY: DATA_VALUE}
    bloom_filter = BloomFilter(db_repository, [], BIT_VECTOR_SIZE)
    bloom_filter.bit_vector = [0, 0, 0, 0, 0]

    hash_ = hashing_function.hash_key(DATA_KEY, BIT_VECTOR_SIZE)

    assert bloom_filter._check_key_existence([hash_]) == False
コード例 #2
0
def test_read_with_existing_key_successfully():

    hash_functions = [hashing_function]
    db_repository = BasicDBRepository()
    db_repository.data_map = {DATA_KEY: DATA_VALUE}
    bloom_filter = BloomFilter(db_repository, hash_functions, BIT_VECTOR_SIZE)
    bloom_filter.bit_vector = [0, 0, 0, 0, 1]

    result = bloom_filter.get_data_with_key(DATA_KEY)

    assert result == DATA_VALUE