Add artifact.1/tests/test_core.py
This commit is contained in:
parent
45ab201043
commit
0793723c2c
1 changed files with 39 additions and 0 deletions
39
artifact.1/tests/test_core.py
Normal file
39
artifact.1/tests/test_core.py
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
import pytest
|
||||
from artifact_1 import core
|
||||
|
||||
class TestAnalyzeRuns:
|
||||
def test_analyze_runs_nominal(self):
|
||||
run_data_list = [
|
||||
{
|
||||
'run_id': 'run_15',
|
||||
'healing_rate': 0.9,
|
||||
'overhead_ms': 120.0,
|
||||
'warn_rate': 0.05,
|
||||
'unknown_rate': 0.01
|
||||
},
|
||||
{
|
||||
'run_id': 'run_16',
|
||||
'healing_rate': 0.95,
|
||||
'overhead_ms': 150.0,
|
||||
'warn_rate': 0.03,
|
||||
'unknown_rate': 0.0
|
||||
}
|
||||
]
|
||||
result = core.analyze_runs(run_data_list)
|
||||
assert result.total_runs == 2
|
||||
assert pytest.approx(result.avg_healing_rate, 0.05) == 0.925
|
||||
assert result.peak_overhead == 150.0
|
||||
assert pytest.approx(result.overall_warn_rate, 0.01) == 0.04
|
||||
|
||||
def test_analyze_runs_empty_input(self):
|
||||
with pytest.raises(ValueError):
|
||||
core.analyze_runs([])
|
||||
|
||||
def test_analyze_runs_invalid_input_type(self):
|
||||
with pytest.raises(TypeError):
|
||||
core.analyze_runs('not_a_list')
|
||||
|
||||
def test_analyze_runs_missing_fields(self):
|
||||
bad_data = [{'run_id': 'run_x', 'healing_rate': 0.9}]
|
||||
with pytest.raises((KeyError, ValueError, TypeError)):
|
||||
core.analyze_runs(bad_data)
|
||||
Loading…
Reference in a new issue