""" The browser's ZIP writer, read back by Python's zipfile. A directory download is assembled in the browser: the node has no idea an archive is being made, so nothing on this side would notice if the bytes were malformed. These tests run the real module under Node, hand the output to zipfile, and check that what comes out is what went in — including the CRCs, which is the field a streaming writer is most likely to get wrong, since it is written after the data it describes. """ import io import json import shutil import subprocess import zipfile from pathlib import Path import pytest STATIC = Path(__file__).resolve().parents[1] / "src" / "meshbay_hub" / "static" ZIPSTREAM = STATIC / "zipstream.js" pytestmark = pytest.mark.skipif( shutil.which("node") is None or not ZIPSTREAM.exists(), reason="node or the SPA sources are not available") def _build(files, force_zip64=False, tmp_path=None): """Run zipstream.js over `files` ({name: bytes}) and return the archive.""" # Copied with an .mjs suffix: the browser loads this file with #