From 0793723c2cee7139537f3a25ed98e7748ebc71ed Mon Sep 17 00:00:00 2001 From: Mika Date: Sun, 8 Mar 2026 11:31:07 +0000 Subject: [PATCH] Add artifact.1/tests/test_core.py --- artifact.1/tests/test_core.py | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 artifact.1/tests/test_core.py diff --git a/artifact.1/tests/test_core.py b/artifact.1/tests/test_core.py new file mode 100644 index 0000000..ed9313f --- /dev/null +++ b/artifact.1/tests/test_core.py @@ -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) \ No newline at end of file