예제 #1
0
def test_auto_close(tmp_path):
    db_path = tmp_path / 'db'
    db = rocksdb3.open_default(str(db_path))

    del db

    assert rocksdb3.open_default(str(db_path)) is not None
예제 #2
0
def test_open_again_should_raises_an_error(tmp_path):
    db_path = tmp_path / 'db'
    _ = rocksdb3.open_default(str(db_path))

    with pytest.raises(rocksdb3.RocksDBError) as excinfo:
        rocksdb3.open_default(str(db_path))

    assert 'can not open' in str(excinfo.value)
예제 #3
0
def test_repair(tmp_path):
    db_path = tmp_path / 'db'
    db = rocksdb3.open_default(str(db_path))
    path = db.path
    del db

    rocksdb3.repair(path)
예제 #4
0
def test_destroy(tmp_path):
    db_path = tmp_path / 'db'
    db = rocksdb3.open_default(str(db_path))
    path = db.path
    del db
    assert Path(path).exists()

    rocksdb3.destroy(path)

    assert not Path(path).exists()
예제 #5
0
def test_secondary(tmp_path):
    primary_path = tmp_path / 'primary'
    db_primary = rocksdb3.open_default(str(primary_path))
    db_primary.put(b'hello', b'world')

    secondary_path = tmp_path / 'secondary'
    db_secondary = rocksdb3.open_as_secondary(str(primary_path),
                                              str(secondary_path))

    assert list(db_secondary.get_iter()) == [(b'hello', b'world')]
예제 #6
0
def test_secondary_catch_up_primary(tmp_path):
    primary_path = tmp_path / 'primary'
    db_primary = rocksdb3.open_default(str(primary_path))
    secondary_path = tmp_path / 'secondary'
    db_secondary = rocksdb3.open_as_secondary(str(primary_path),
                                              str(secondary_path))
    assert db_secondary.get(b'author') == None
    db_primary.put(b'author', b'xyb')

    db_secondary.try_catch_up_with_primary()

    assert db_secondary.get(b'author') == b'xyb'
예제 #7
0
def test_repair_should_not_be_used_on_db_that_is_in_using(tmp_path):
    db_path = tmp_path / 'db'
    db = rocksdb3.open_default(str(db_path))

    with pytest.raises(rocksdb3.RocksDBError):
        rocksdb3.repair(db.path)
예제 #8
0
def test_destroy_should_not_delete_db_that_is_in_using(tmp_path):
    db_path = tmp_path / 'db'
    db = rocksdb3.open_default(str(db_path))

    with pytest.raises(rocksdb3.RocksDBError):
        rocksdb3.destroy(db.path)
예제 #9
0
def test_open_default(tmp_path):
    db_path = tmp_path / 'db'
    db = rocksdb3.open_default(str(db_path))

    assert db.get(b'open') is None
예제 #10
0
def db(tmp_path):
    db_path = tmp_path / 'db'
    db = rocksdb3.open_default(str(db_path))
    return db