40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
import scripts.benchmark as benchmark
|
|
|
|
|
|
def test_load_benchmark_dataset():
|
|
dataset = benchmark.load_benchmark_dataset(Path("fixtures/benchmark/quality_benchmark.json"))
|
|
assert dataset["dataset_version"] == "vr116-2026-07-21"
|
|
assert isinstance(dataset["parser_coverage"], list)
|
|
assert isinstance(dataset["dedupe"], dict)
|
|
|
|
|
|
def test_percentile_helper_is_deterministic():
|
|
assert benchmark._percentile([1.0, 2.0, 3.0, 4.0], 50) == 2.0
|
|
assert benchmark._percentile([], 95) == 0.0
|
|
|
|
|
|
@pytest.mark.django_db
|
|
def test_run_benchmark_report_smoke(db):
|
|
report = benchmark.run_benchmark_report(
|
|
Path("fixtures/benchmark/quality_benchmark.json"),
|
|
quick=True,
|
|
top_n=20,
|
|
jobs=25,
|
|
skip_performance=True,
|
|
)
|
|
|
|
assert report["status"] in {"passed", "failed"}
|
|
assert report["jobs_processed"] == 25
|
|
assert report["top_n"] == 20
|
|
assert report["performance"]["status"] == "skipped"
|
|
assert report["nfr_007"]["measured"] is False
|
|
assert set(report["hardware"].keys()) >= {"platform", "python", "cpu_count"}
|
|
assert report["parser"]["coverage_ratio"] >= 0
|
|
assert report["ranking"]["top_n"] == 20
|