Download tests/test_end_to_end.py from InternsProgressUpdate/Venket: direct link, hf CLI and curl.
- Browser
- Download file 2.13 kB
-
https://huggingface.co/InternsProgressUpdate/Venket/resolve/main/tests/test_end_to_end.py
- Command line
-
hf download hf://InternsProgressUpdate/Venket/tests/test_end_to_end.py
-
curl -L -o test_end_to_end.py https://huggingface.co/InternsProgressUpdate/Venket/resolve/main/tests/test_end_to_end.py
2.13 kB
| """End-to-end integration tests running the full pipeline against the real bundled assets.""" | |
| from __future__ import annotations | |
| import json | |
| import numpy as np | |
| from src.config.loader import load_config | |
| from src.generator import GeneratorContext | |
| def _make_context(tmp_path, seed: int = 123): | |
| overrides = [ | |
| f"paths.output_dir={tmp_path.as_posix()}", | |
| "generation.count=1", | |
| ] | |
| config = load_config(overrides=[f"seed={seed}"] + overrides) | |
| return config, GeneratorContext(config) | |
| def test_run_sample_produces_complete_metadata(tmp_path): | |
| config, ctx = _make_context(tmp_path) | |
| metadata, final_image, validation_report = ctx.run_sample(1) | |
| assert isinstance(final_image, np.ndarray) | |
| assert final_image.ndim == 3 and final_image.shape[2] == 3 | |
| assert final_image.dtype == np.uint8 | |
| for key in ("document_id", "template", "signer", "difficulty", "quality", "augmentation", "geometry", "metrics"): | |
| assert key in metadata | |
| assert validation_report is not None | |
| assert validation_report.passed, [i.message for i in validation_report.issues] | |
| def test_run_sample_is_fully_reproducible(tmp_path): | |
| config, ctx = _make_context(tmp_path, seed=555) | |
| metadata1, image1, _ = ctx.run_sample(42) | |
| metadata2, image2, _ = ctx.run_sample(42) | |
| assert np.array_equal(image1, image2) | |
| metadata1.pop("provenance", None) | |
| metadata2.pop("provenance", None) | |
| assert json.dumps(metadata1, sort_keys=True, default=str) == json.dumps(metadata2, sort_keys=True, default=str) | |
| def test_different_sample_indices_produce_different_documents(tmp_path): | |
| config, ctx = _make_context(tmp_path, seed=555) | |
| metadata1, image1, _ = ctx.run_sample(1) | |
| metadata2, image2, _ = ctx.run_sample(2) | |
| assert not np.array_equal(image1, image2) or metadata1["signer"] != metadata2["signer"] | |
| def test_difficulty_tier_is_one_of_expected_values(tmp_path): | |
| config, ctx = _make_context(tmp_path, seed=7) | |
| metadata, _, _ = ctx.run_sample(1) | |
| assert metadata["difficulty"]["tier"] in ("easy", "medium", "hard") | |
| assert 0.0 <= metadata["difficulty"]["score"] <= 1.0 | |