mirror of
https://github.com/elder-plinius/OBLITERATUS.git
synced 2026-12-05 18:44:41 +01:00
35 lines
1.4 KiB
Python
35 lines
1.4 KiB
Python
"""Invalid evaluation requests must fail before loading or mutating a model."""
|
|
|
|
from types import SimpleNamespace
|
|
from unittest.mock import Mock
|
|
|
|
import pytest
|
|
|
|
from obliteratus import checkpoint_evaluation
|
|
from obliteratus.ui_concept_lab import ConceptLabSession
|
|
|
|
pytestmark = pytest.mark.cpu
|
|
|
|
|
|
@pytest.mark.parametrize("max_prompts", [0, -1, True, 1.5, "10"])
|
|
def test_checkpoint_evaluation_rejects_invalid_prompt_limit_before_loading(
|
|
tmp_path, monkeypatch, max_prompts,
|
|
):
|
|
lifecycle = Mock()
|
|
constructor = Mock(side_effect=AssertionError("invalid request reached model loading"))
|
|
monkeypatch.setattr(checkpoint_evaluation, "from_environment", lambda: lifecycle)
|
|
monkeypatch.setattr(checkpoint_evaluation, "AbliterationPipeline", constructor)
|
|
with pytest.raises(ValueError, match="max_prompts must be a positive integer"):
|
|
checkpoint_evaluation.evaluate_checkpoint(
|
|
tmp_path, partition="final_test", max_prompts=max_prompts,
|
|
)
|
|
constructor.assert_not_called()
|
|
lifecycle.loading.assert_not_called()
|
|
lifecycle.release.assert_called_once_with(reason="evaluation_final_test_complete")
|
|
|
|
|
|
def test_concept_lab_evaluation_requires_an_active_intervention():
|
|
session = SimpleNamespace(run=None)
|
|
with pytest.raises(ValueError, match="Apply an intervention before evaluating"):
|
|
ConceptLabSession.evaluate(session)
|