Add trace_agg/tests/test_core.py
This commit is contained in:
parent
3664b2f22b
commit
cdfb9cdad3
1 changed files with 51 additions and 0 deletions
51
trace_agg/tests/test_core.py
Normal file
51
trace_agg/tests/test_core.py
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
import json
|
||||
import pytest
|
||||
from trace_agg import core
|
||||
|
||||
@pytest.fixture
|
||||
def sample_trace_data():
|
||||
# Simuliert TraceData-Struktur gemäss data_model
|
||||
return [
|
||||
{
|
||||
"entry_time": 100.0,
|
||||
"first_read_time": 150.0,
|
||||
"baseline_recalc_time": 200.0,
|
||||
"delta": 0.0
|
||||
},
|
||||
{
|
||||
"entry_time": 110.0,
|
||||
"first_read_time": 160.0,
|
||||
"baseline_recalc_time": 215.0,
|
||||
"delta": 0.0
|
||||
}
|
||||
]
|
||||
|
||||
def test_aggregate_traces_returns_list(sample_trace_data):
|
||||
result = core.aggregate_traces(sample_trace_data)
|
||||
assert isinstance(result, list)
|
||||
|
||||
def test_aggregate_traces_computes_deltas(sample_trace_data):
|
||||
result = core.aggregate_traces(sample_trace_data)
|
||||
assert all(isinstance(item, dict) for item in result)
|
||||
# Überprüft Delta-Kettenlogik: Differenzen sollen positiv sein
|
||||
for chain in result:
|
||||
if 'd_entry_first' in chain:
|
||||
assert chain['d_entry_first'] > 0
|
||||
if 'd_first_recalc' in chain:
|
||||
assert chain['d_first_recalc'] > 0
|
||||
|
||||
def test_aggregate_traces_handles_empty_list():
|
||||
result = core.aggregate_traces([])
|
||||
assert result == []
|
||||
|
||||
def test_aggregate_traces_maintains_trace_order(sample_trace_data):
|
||||
result = core.aggregate_traces(sample_trace_data)
|
||||
# Sicherstellen, dass Reihenfolge analog Input bleibt
|
||||
assert len(result) == len(sample_trace_data)
|
||||
|
||||
|
||||
def test_trace_data_format_integrity(sample_trace_data):
|
||||
# Inputdaten sind valide nach data_model
|
||||
for td in sample_trace_data:
|
||||
assert set(td.keys()) == {"entry_time", "first_read_time", "baseline_recalc_time", "delta"}
|
||||
assert all(isinstance(td[k], float) for k in td)
|
||||
Loading…
Reference in a new issue