Spaces:
Running on T4
Running on T4
Download tests/test_pitching_ml_coach_validation.py from modventures/baseball-engine: direct link, hf CLI and curl.
- Browser
- Download file 1.25 kB
-
https://huggingface.co/spaces/modventures/baseball-engine/resolve/main/tests/test_pitching_ml_coach_validation.py
- Command line
-
hf download hf://spaces/modventures/baseball-engine/tests/test_pitching_ml_coach_validation.py
-
curl -L -o test_pitching_ml_coach_validation.py https://huggingface.co/spaces/modventures/baseball-engine/resolve/main/tests/test_pitching_ml_coach_validation.py
1.25 kB
| """Audit utility must not overwrite evidence or accept a substituted source video.""" | |
| import hashlib | |
| import pytest | |
| from tools.validate_pitching_ml_coach import AuditError, check_output, verify_file | |
| def test_audit_output_guard_preserves_existing_and_source_evidence(tmp_path): | |
| source = tmp_path / "source" | |
| source.mkdir() | |
| sentinel = source / "manifest.json" | |
| sentinel.write_text("original evidence") | |
| existing = tmp_path / "existing" | |
| existing.mkdir() | |
| for output in (source, source / "new-audit", existing): | |
| with pytest.raises(AuditError): | |
| check_output(source, output) | |
| assert sentinel.read_text() == "original evidence" | |
| assert not (source / "new-audit").exists() | |
| check_output(source, tmp_path / "new-audit") | |
| def test_audit_rejects_same_length_substituted_video(tmp_path): | |
| video = tmp_path / "clip.mp4" | |
| original = b"original-source-video" | |
| video.write_bytes(original) | |
| checksum = hashlib.sha256(original).hexdigest() | |
| verify_file(video, checksum, len(original)) | |
| video.write_bytes(b"substitute-source-vid") | |
| assert video.stat().st_size == len(original) | |
| with pytest.raises(AuditError, match="checksum mismatch"): | |
| verify_file(video, checksum, len(original)) | |