Skip to content

Commit eb25002

Browse files
committed
Add async and sync iterable put tests
1 parent 94fcab5 commit eb25002

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/test_put.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import itertools
2+
13
import pytest
24

35
import obstore as obs
@@ -39,3 +41,33 @@ def test_put_mode():
3941
obs.put(store, "file1.txt", b"foo", mode="create")
4042

4143
assert obs.get(store, "file1.txt").bytes() == b"bar"
44+
45+
46+
@pytest.mark.asyncio
47+
async def test_put_async_iterable():
48+
store = MemoryStore()
49+
50+
data = b"the quick brown fox jumps over the lazy dog," * 50_000
51+
path = "big-data.txt"
52+
53+
await obs.put_async(store, path, data)
54+
55+
resp = await obs.get_async(store, path)
56+
stream = resp.stream(min_chunk_size=0)
57+
new_path = "new-path.txt"
58+
await obs.put_async(store, new_path, stream)
59+
60+
assert obs.get(store, new_path).bytes() == data
61+
62+
63+
def test_put_sync_iterable():
64+
store = MemoryStore()
65+
66+
b = b"the quick brown fox jumps over the lazy dog,"
67+
iterator = itertools.repeat(b, 50_000)
68+
data = b * 50_000
69+
path = "big-data.txt"
70+
71+
obs.put(store, path, iterator)
72+
73+
assert obs.get(store, path).bytes() == data

0 commit comments

Comments
 (0)