Skip to content

Commit 7bc5a38

Browse files
committed
Add unit test for ChunkStream
1 parent 3371b59 commit 7bc5a38

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test/test_core.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import json
22
import pathlib
3+
from io import BufferedReader
4+
35
import pytest
46
from unittest.mock import Mock
57

@@ -10,6 +12,8 @@
1012

1113
from unittest.mock import MagicMock, patch
1214

15+
from xcengine.core import ChunkStream
16+
1317

1418
def test_init_runner_invalid_image_type():
1519
with pytest.raises(ValueError, match='Invalid type "int"'):
@@ -72,3 +76,12 @@ def test_pip(mock_run):
7276
assert not inspector.is_local("textdistance")
7377
assert not inspector.is_local("pip")
7478
assert not inspector.is_local("setuptools")
79+
80+
81+
def test_chunk_stream():
82+
chunks = ["123", "456", "789", "abc"]
83+
expected = "".join(chunks).encode()
84+
bytegen = (chunk.encode() for chunk in chunks)
85+
chunk_stream = ChunkStream(bytegen)
86+
assert chunk_stream.readable()
87+
assert BufferedReader(chunk_stream).read() == expected

0 commit comments

Comments
 (0)