Пример #1
0
def test_read_attr_gt_fail(context):
    context.write_full('foo', b'Hello world!')
    context.set_xattr('foo', 'attr', b'b')

    rop = context.read_op_create()
    rop.cmpxattr('attr', rados.CmpXattrOp.gt, b'a')
    with pytest.raises(rados.Canceled):
        context.read_op_operate('foo', rop)
Пример #2
0
def test_read_attr_cmp_eq_fail(context):
    context.write_full('foo', b'Hello world!')
    context.set_xattr('foo', 'version', b'3.14')

    rop = context.read_op_create()
    rop.cmpxattr('version', rados.CmpXattrOp.eq, b'2.71')
    with pytest.raises(rados.Canceled):
        context.read_op_operate('foo', rop)
Пример #3
0
def test_read_xattrs(context):
    context.set_xattr('foo', 'a', b'b')

    rop = context.read_op_create()
    rop.get_xattrs()
    context.read_op_operate('foo', rop)

    assert {'a': b'b'} == dict(rop.get_xattrs_data())
Пример #4
0
def test_set_get(context):
    context.write_full('foo', b'bar')

    with pytest.raises(rados.NoData):
        context.get_xattr('foo', 'a')

    context.set_xattr('foo', 'a', b'b')
    assert b'b' == context.get_xattr('foo', 'a')
Пример #5
0
def test_read_attr_gt(context):
    context.write_full('foo', b'Hello world!')
    context.set_xattr('foo', 'attr', b'a')

    rop = context.read_op_create()
    rop.cmpxattr('attr', rados.CmpXattrOp.gt, b'b')
    rop.stat()
    context.read_op_operate('foo', rop)
    assert 12 == rop.size()
Пример #6
0
def test_read_attr_cmp_eq(context):
    context.write_full('foo', b'Hello world!')
    context.set_xattr('foo', 'version', b'3.14')

    rop = context.read_op_create()
    rop.cmpxattr('version', rados.CmpXattrOp.eq, b'3.14')
    rop.stat()
    context.read_op_operate('foo', rop)
    assert 12 == rop.size()
Пример #7
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')
Пример #8
0
def test_xatrrs(context):
    try:
        context.remove('foo')
    except rados.ObjectNotFound:
        pass

    with pytest.raises(rados.ObjectNotFound):
        context.get_xattrs('foo')

    for i in range(10):
        context.set_xattr('foo', 'key{}'.format(i), 'value{}'.format(i).encode('ascii'))

    attrs = context.get_xattrs('foo')
    assert isinstance(attrs, rados.XattrIterator)

    attrs = dict(attrs)
    assert 10 == len(attrs)
    assert 'key1' in attrs
    assert b'value1' == attrs['key1']