Add trace_agg/tests/test_core.py
This commit is contained in:
parent
65bfe40bf9
commit
e3c5f47947
1 changed files with 35 additions and 0 deletions
35
trace_agg/tests/test_core.py
Normal file
35
trace_agg/tests/test_core.py
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
import pytest
|
||||||
|
from trace_agg import core
|
||||||
|
|
||||||
|
def test_aggregate_em_data_returns_dict():
|
||||||
|
result = core.aggregate_em_data(num_trials=5)
|
||||||
|
assert isinstance(result, dict), 'Ergebnis muss ein Dictionary sein.'
|
||||||
|
|
||||||
|
|
||||||
|
def test_summary_statistics_keys_present():
|
||||||
|
result = core.aggregate_em_data(num_trials=3)
|
||||||
|
expected_keys = {'peak_amplitude', 'median_bandpower', 'crosscorr_with_clockevents'}
|
||||||
|
assert expected_keys.issubset(result.keys()), 'Alle Schlüssel der Summary-Statistik müssen vorhanden sein.'
|
||||||
|
|
||||||
|
|
||||||
|
def test_value_ranges():
|
||||||
|
result = core.aggregate_em_data(num_trials=10)
|
||||||
|
# Wertebereiche prüfen
|
||||||
|
assert 0 <= result['peak_amplitude'] < 1e6, 'peak_amplitude unrealistischer Wert.'
|
||||||
|
assert 0 <= result['median_bandpower'] < 1e5, 'median_bandpower außerhalb erwarteten Bereichs.'
|
||||||
|
assert -1 <= result['crosscorr_with_clockevents'] <= 1, 'crosscorr_with_clockevents muss zwischen -1 und 1 liegen.'
|
||||||
|
|
||||||
|
|
||||||
|
def test_consistency_multiple_calls():
|
||||||
|
r1 = core.aggregate_em_data(num_trials=10)
|
||||||
|
r2 = core.aggregate_em_data(num_trials=10)
|
||||||
|
# Aufgrund von deterministischer Logik sollten Werte konsistent sein
|
||||||
|
assert set(r1.keys()) == set(r2.keys())
|
||||||
|
for key in r1:
|
||||||
|
assert isinstance(r1[key], float)
|
||||||
|
assert isinstance(r2[key], float)
|
||||||
|
|
||||||
|
|
||||||
|
def test_invalid_num_trials():
|
||||||
|
with pytest.raises(ValueError):
|
||||||
|
core.aggregate_em_data(num_trials=-5)
|
||||||
Loading…
Reference in a new issue