Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /Consiliency_treesitter-chunker /tests /test_grammar_integrity.py
| """Regression tests for grammar artifact provenance.""" | |
| import hashlib | |
| from pathlib import Path | |
| import pytest | |
| from chunker.grammar.download import GrammarDownloadManager | |
| from chunker.grammar.integrity import ArtifactIntegrityError, verify_artifact | |
| def test_verify_artifact_rejects_checksum_mismatch(tmp_path): | |
| artifact = tmp_path / "grammar.tar.gz" | |
| artifact.write_bytes(b"untrusted") | |
| with pytest.raises(ArtifactIntegrityError, match="checksum"): | |
| verify_artifact(artifact, {"sha256": "0" * 64}) | |
| def test_download_refuses_bare_master_default(tmp_path): | |
| with pytest.raises(ValueError, match="immutable commit"): | |
| GrammarDownloadManager(cache_dir=tmp_path).download_grammar("python") | |
| def test_download_verifies_manifest_before_extract(tmp_path, monkeypatch): | |
| manager = GrammarDownloadManager(cache_dir=tmp_path) | |
| payload = b"trusted archive" | |
| checksum = hashlib.sha256(payload).hexdigest() | |
| monkeypatch.setattr( | |
| manager, | |
| "ARTIFACT_MANIFEST", | |
| {"python@0123456789abcdef": {"sha256": checksum}}, | |
| ) | |
| monkeypatch.setattr( | |
| manager, | |
| "_download_file", | |
| lambda _url, destination, _language, _progress: Path(destination).write_bytes( | |
| payload, | |
| ), | |
| ) | |
| monkeypatch.setattr( | |
| manager, | |
| "_extract_archive", | |
| lambda _archive, destination: destination.mkdir(exist_ok=True), | |
| ) | |
| assert manager.download_grammar("python", "0123456789abcdef").exists() | |
Xet Storage Details
- Size:
- 1.49 kB
- Xet hash:
- f043f916550b508c82c0da67833bd92befb938d3b3ac8ad528c36d6edd0889b1
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.