Пример #1
0
def test_write_remove(context):
    context.write_full('foo', b'bar')

    wop = context.write_op_create()
    wop.assert_exists()
    wop.remove()
    context.write_op_operate('foo', wop)

    with pytest.raises(rados.ObjectNotFound):
        context.read('foo')
Пример #2
0
def test_namespace(context):
    assert '' == context.get_namespace()
    context.set_namespace('test_namespace')
    assert 'test_namespace' == context.get_namespace()

    context.set_namespace('tn1')
    context.write_full("foo", b'1')
    assert b'1' == context.read('foo')

    context.set_namespace('tn2')
    context.write_full("foo", b'2')
    assert b'2' == context.read('foo')

    context.set_namespace('tn1')
    assert b'1' == context.read('foo')
Пример #3
0
def test_simple_write(context):
    try:
        context.remove('foo')
    except rados.ObjectNotFound:
        pass

    context.write('foo', b'The quick brown fox jumps over the lazy dog')
    assert b'The quick brown fox jumps over the lazy dog' == context.read('foo')
Пример #4
0
def test_write_append(context):
    context.write_full('foo', b'bar')

    wop = context.write_op_create()
    wop.append(b'baz')
    context.write_op_operate('foo', wop)

    assert b'barbaz' == context.read('foo')
Пример #5
0
def test_write_assert(context):
    context.write_full('foo', b'bar')

    wop = context.write_op_create()
    wop.assert_exists()
    wop.write_full(b'baz')
    context.write_op_operate('foo', wop)

    assert b'baz' == context.read('foo')
Пример #6
0
def test_write_attr_cmp_eq(context):
    context.write_full('foo', b'Hello world!')
    context.set_xattr('foo', 'version', b'3.14')

    wop = context.write_op_create()
    wop.cmpxattr('version', rados.CmpXattrOp.eq, b'3.14')
    wop.write_full(b'bar')
    context.write_op_operate('foo', wop)

    assert b'bar' == context.read('foo')
Пример #7
0
def test_write_create(context):
    try:
        context.remove('foo')
    except rados.ObjectNotFound:
        pass

    wop = context.write_op_create()
    wop.create(True)
    wop.write_full(b'bar')
    context.write_op_operate('foo', wop)

    assert b'bar' == context.read('foo')
Пример #8
0
def test_small_buffer_read(context):
    context.write_full('foo', b'The quick brown fox jumps over the lazy dog')
    assert b'The quick' == context.read('foo', length=9)
Пример #9
0
def test_simple_read(context):
    context.write_full('foo', b'The quick brown fox jumps over the lazy dog')
    assert b'The quick brown fox jumps over the lazy dog' == context.read('foo')
Пример #10
0
def test_offset_write(context):
    context.write_full('foo', b'The quick brown fox jumps over the lazy dog')
    context.write('foo', b'flies', offset=20)
    assert b'The quick brown fox flies over the lazy dog' == context.read('foo')
Пример #11
0
def test_offset_and_len_read(context):
    context.write_full('foo', b'The quick brown fox jumps over the lazy dog')
    assert b'jumps' == context.read('foo', length=5, offset=20)
Пример #12
0
def test_offset_read(context):
    context.write_full('foo', b'The quick brown fox jumps over the lazy dog')
    assert b'brown fox jumps over the lazy dog' == context.read('foo', offset=10)
Пример #13
0
def test_write_simple(context):
    wop = context.write_op_create()
    wop.write_full(b'bar')
    context.write_op_operate('foo', wop)

    assert b'bar' == context.read('foo')
Пример #14
0
def test_remove(context):
    assert 0 == context.write_full("foo", b'bar')
    assert b'bar' == context.read('foo')
    context.remove('foo')
    with pytest.raises(rados.ObjectNotFound) as e:
        context.stat('foo')
Пример #15
0
def test_simple_rw(context):
    assert 0 == context.write_full("foo", b'bar')
    assert b'bar' == context.read('foo')