import json import pytest from h3_mlx.hub import sha256 from scripts.publish_hf_release import publish_component, verify_local def test_partial_quantized_export_cannot_be_published(tmp_path): core = tmp_path / "model/core" core.mkdir(parents=True) file = core / "quantization.json" file.write_text( json.dumps( { "files": [ { "file": f"core-{i:03d}.safetensors", "bytes": 1, "sha256": "a" * 64, } for i in range(52) ] } ) ) (tmp_path / "files.json").write_text( json.dumps( { "format": "h3-mlx-files-v1", "files": { "model/core/quantization.json": { "bytes": file.stat().st_size, "sha256": sha256(file), }, }, } ) ) with pytest.raises(ValueError, match="export/manifest mismatch"): verify_local(tmp_path) def test_partial_packed_export_cannot_create_or_modify_a_repository(tmp_path): (tmp_path / "model/core").mkdir(parents=True) # No API method exists: an attempted remote mutation would fail this test. with pytest.raises(ValueError, match="fifty packed blocks"): publish_component(object(), "packed12", tmp_path)