ethicsguard / tests /test_generator.py
GodreignElgin
test
37b04ce
from ethicsguard.generator import DIFFICULTY_CONFIG, SEED_REGISTRY, generate_queue
def test_generator_is_deterministic() -> None:
assert generate_queue(seed=1000, difficulty="easy") == generate_queue(seed=1000, difficulty="easy")
def test_generator_matches_aggregate_null_hint_ratio() -> None:
for difficulty, splits in SEED_REGISTRY.items():
seeds = splits["train"] + splits["eval"]
total_items = 0
total_null_hints = 0
for seed in seeds:
queue = generate_queue(seed=seed, difficulty=difficulty)
total_items += len(queue)
total_null_hints += sum(1 for item in queue if item.risk_score_hint is None)
expected_ratio = float(DIFFICULTY_CONFIG[difficulty]["null_hint_ratio"])
assert total_null_hints == round(total_items * expected_ratio)
def test_generator_preserves_queue_size_by_difficulty() -> None:
for difficulty, config in DIFFICULTY_CONFIG.items():
queue = generate_queue(seed=SEED_REGISTRY[difficulty]["train"][0], difficulty=difficulty)
assert len(queue) == int(config["queue_size"])