def test_read_with_assertion(context): context.write_full('foo', b'bar') rop = context.read_op_create() rop.assert_exists() rop.read() context.read_op_operate('foo', rop) assert b'bar' == rop.read_data()
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)
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)
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())
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()
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()
def test_read_stat(context): context.write_full('foo', b'Hello world!') rop = context.read_op_create() rop.assert_exists() rop.stat() context.read_op_operate('foo', rop) assert 12 == rop.size() diff = datetime.now() - datetime.fromtimestamp(mktime(rop.mtime())) assert 5 > diff.total_seconds()
def test_read_with_assertion(context): try: context.remove('foo') except rados.ObjectNotFound: pass rop = context.read_op_create() rop.assert_exists() rop.read() with pytest.raises(rados.ObjectNotFound): context.read_op_operate('foo', rop)
def test_simple_read(context): context.write_full('foo', b'bar') rop = context.read_op_create() rop.read() context.read_op_operate('foo', rop) assert b'bar' == rop.read_data()