def test_roundtrip_write_only(tmpdir): b = WriteBucket(7, 1, dir=tmpdir.strpath, format=HexWriter) prefix = b.prefix() assert prefix == 'source_7_split_1_' listdir = tmpdir.listdir() assert listdir == [] b.addpair((4, 'test'), write_only=True) b.collect([(3, 'a'), (1, 'This'), (2, 'is')], write_only=True) values = ' '.join(value for key, value in b) assert values == '' b.close_writer(do_sync=False) filename = prefix + '.mrsx' path = tmpdir.join(filename).strpath listdir = tmpdir.listdir() assert listdir == [path] readonly_copy = b.readonly_copy() assert readonly_copy.url == path values = ' '.join(value for key, value in readonly_copy) assert values == '' values = ' '.join(value for key, value in readonly_copy.stream()) assert values == 'test a This is' b.clean() listdir = tmpdir.listdir() assert listdir == []
def test_write_only(): b = WriteBucket(0, 0) b.addpair((4, 'test'), write_only=True) b.collect([(3, 'a'), (1, 'This'), (2, 'is')], write_only=True) values = ' '.join(value for key, value in b) assert values == '' readonly_copy = b.readonly_copy() assert readonly_copy.url is None
def test_writebucket(): b = WriteBucket(0, 0) b.addpair((4, 'test')) b.collect([(3, 'a'), (1, 'This'), (2, 'is')]) values = ' '.join(value for key, value in b) assert values == 'test a This is' b.sort() values = ' '.join(value for key, value in b) assert values == 'This is a test'