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')
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_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')
def test_write_assert_fail(context): try: context.remove('foo') except rados.ObjectNotFound: pass wop = context.write_op_create() wop.assert_exists() wop.write_full(b'baz') with pytest.raises(rados.ObjectNotFound): context.write_op_operate('foo', wop)
def test_omap_write(context): try: context.remove('foo') except rados.ObjectNotFound: pass wop = context.write_op_create() wop.omap_set({'Hello': b'world!'}) context.write_op_operate('foo', wop) assert {'Hello': b'world!'} == dict(context.omap_iter('foo'))
def test_omap_sequence(context): try: context.remove('foo') except rados.ObjectNotFound: pass kv = {"test_id:{}".format(i): str(i).encode('utf-8') for i in range(9, -1, -1)} wop = context.write_op_create() wop.omap_set(kv) context.write_op_operate('foo', wop) omaplist = context.omap_iter('foo') for i, (k, v) in enumerate(omaplist): assert 'test_id:{}'.format(i) == k assert str(i).encode('utf-8') == v
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']
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')