Skip to content

Commit 134cea5

Browse files
committed
Added test_stream.
1 parent 974687d commit 134cea5

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,35 @@
1+
from tempfile import TemporaryDirectory
2+
from pathlib import Path
3+
from uuid import uuid4
4+
15
from ..outputs import OutputsManager
26

7+
text = ''.join([str(i) for i in range(10)])
8+
9+
def so(i):
10+
return {
11+
"output_type": "stream",
12+
"name": "stdout",
13+
"text": str(i),
14+
}
15+
16+
stream_outputs = list([so(i) for i in range(10)])
17+
18+
319
def test_instantiation():
420
op = OutputsManager()
21+
assert isinstance(op, OutputsManager)
22+
23+
def test_stream():
24+
with TemporaryDirectory() as td:
25+
op = OutputsManager()
26+
op.outputs_path = Path(td) / "outputs"
27+
file_id = str(uuid4())
28+
cell_id = str(uuid4())
29+
output_index = 0
30+
assert op._build_path(file_id, cell_id, output_index) == \
31+
op.outputs_path / file_id / cell_id / f"{output_index}.output"
32+
for stream in stream_outputs:
33+
op.write_stream(file_id, cell_id, stream)
34+
assert op.get_stream(file_id, cell_id) == text
535

0 commit comments

Comments
 (0)