|
|
import numpy as np |
|
|
import pytest |
|
|
import torch |
|
|
from types import SimpleNamespace |
|
|
|
|
|
from cognitive_mapping_probe.orchestrator_seismograph import run_seismic_analysis |
|
|
|
|
|
def test_seismic_analysis_orchestrator_no_injection(mocker, mock_llm): |
|
|
""" |
|
|
Testet den Orchestrator im Baseline-Modus (ohne Injektion). |
|
|
""" |
|
|
mock_deltas = [1.0, 2.0, 3.0] |
|
|
mock_run_seismic = mocker.patch('cognitive_mapping_probe.orchestrator_seismograph.run_silent_cogitation_seismic', return_value=mock_deltas) |
|
|
|
|
|
mock_progress = mocker.MagicMock() |
|
|
|
|
|
results = run_seismic_analysis( |
|
|
model_id="mock_model", |
|
|
prompt_type="test_prompt", |
|
|
seed=42, |
|
|
num_steps=3, |
|
|
concept_to_inject="", |
|
|
injection_strength=0.0, |
|
|
progress_callback=mock_progress |
|
|
) |
|
|
|
|
|
|
|
|
mock_run_seismic.assert_called_once() |
|
|
call_args, call_kwargs = mock_run_seismic.call_args |
|
|
assert call_kwargs['injection_vector'] is None |
|
|
|
|
|
|
|
|
assert results["stats"]["mean_delta"] == pytest.approx(2.0) |
|
|
|
|
|
def test_seismic_analysis_orchestrator_with_injection(mocker, mock_llm): |
|
|
""" |
|
|
Testet den Orchestrator mit aktivierter Konzeptinjektion. |
|
|
""" |
|
|
mock_deltas = [5.0, 6.0, 7.0] |
|
|
mock_run_seismic = mocker.patch('cognitive_mapping_probe.orchestrator_seismograph.run_silent_cogitation_seismic', return_value=mock_deltas) |
|
|
|
|
|
|
|
|
mock_get_concept_vector = mocker.patch('cognitive_mapping_probe.orchestrator_seismograph.get_concept_vector') |
|
|
|
|
|
mock_progress = mocker.MagicMock() |
|
|
|
|
|
results = run_seismic_analysis( |
|
|
model_id="mock_model", |
|
|
prompt_type="test_prompt", |
|
|
seed=42, |
|
|
num_steps=3, |
|
|
concept_to_inject="test_concept", |
|
|
injection_strength=1.5, |
|
|
progress_callback=mock_progress |
|
|
) |
|
|
|
|
|
|
|
|
mock_get_concept_vector.assert_called_once_with(mocker.ANY, "test_concept") |
|
|
|
|
|
|
|
|
mock_run_seismic.assert_called_once() |
|
|
call_args, call_kwargs = mock_run_seismic.call_args |
|
|
assert call_kwargs['injection_vector'] is not None |
|
|
assert call_kwargs['injection_strength'] == 1.5 |
|
|
|
|
|
|
|
|
assert results["stats"]["mean_delta"] == pytest.approx(6.0) |
|
|
|