Files
StarPilot/common/tests/test_file_chunker.py
T
firestar5683 8b7c2b5f36 oo buddy boy
2026-07-20 13:18:27 -05:00

17 lines
594 B
Python

from openpilot.common import file_chunker
def test_chunked_stream_round_trip(tmp_path, monkeypatch):
monkeypatch.setattr(file_chunker, "CHUNK_SIZE", 7)
path = tmp_path / "artifact.pkl"
payload = b"a model artifact spanning several chunks"
path.write_bytes(payload)
targets = file_chunker.get_chunk_targets(path, len(payload))
file_chunker.chunk_file(path, targets)
assert file_chunker.file_chunked_exists(path)
assert file_chunker.read_file_chunked(path) == payload
with file_chunker.open_file_chunked(path) as stream:
assert stream.read(9) + stream.read() == payload