initial commit
This commit is contained in:
0
tests/test_protocol/__init__.py
Normal file
0
tests/test_protocol/__init__.py
Normal file
BIN
tests/test_protocol/__pycache__/__init__.cpython-312.pyc
Normal file
BIN
tests/test_protocol/__pycache__/__init__.cpython-312.pyc
Normal file
Binary file not shown.
BIN
tests/test_protocol/__pycache__/__init__.cpython-314.pyc
Normal file
BIN
tests/test_protocol/__pycache__/__init__.cpython-314.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
71
tests/test_protocol/test_euro_ncap.py
Normal file
71
tests/test_protocol/test_euro_ncap.py
Normal file
@@ -0,0 +1,71 @@
|
||||
"""Tests for Euro NCAP scoring."""
|
||||
|
||||
import pytest
|
||||
|
||||
from impakt.criteria.base import CriterionResult
|
||||
from impakt.protocol.euro_ncap import EuroNCAP, evaluate
|
||||
|
||||
|
||||
class TestEuroNCAP:
|
||||
@pytest.fixture
|
||||
def good_criteria(self):
|
||||
"""Criteria results that should score well."""
|
||||
return {
|
||||
"HIC15": CriterionResult(criterion="HIC15", value=400, body_region="Head"),
|
||||
"3ms Clip": CriterionResult(
|
||||
criterion="3ms Clip", value=38, unit="g", body_region="Chest"
|
||||
),
|
||||
"Chest Deflection": CriterionResult(
|
||||
criterion="Chest Deflection", value=20, unit="mm", body_region="Chest"
|
||||
),
|
||||
"Nij": CriterionResult(criterion="Nij", value=0.4, body_region="Neck"),
|
||||
"Femur Load Left": CriterionResult(
|
||||
criterion="Femur Load Left", value=3.0, unit="kN", body_region="Femur Left"
|
||||
),
|
||||
"Femur Load Right": CriterionResult(
|
||||
criterion="Femur Load Right", value=3.2, unit="kN", body_region="Femur Right"
|
||||
),
|
||||
}
|
||||
|
||||
@pytest.fixture
|
||||
def poor_criteria(self):
|
||||
"""Criteria results that should score poorly."""
|
||||
return {
|
||||
"HIC15": CriterionResult(criterion="HIC15", value=1200, body_region="Head"),
|
||||
"3ms Clip": CriterionResult(
|
||||
criterion="3ms Clip", value=65, unit="g", body_region="Chest"
|
||||
),
|
||||
"Chest Deflection": CriterionResult(
|
||||
criterion="Chest Deflection", value=70, unit="mm", body_region="Chest"
|
||||
),
|
||||
"Nij": CriterionResult(criterion="Nij", value=1.5, body_region="Neck"),
|
||||
}
|
||||
|
||||
def test_good_results_high_stars(self, good_criteria):
|
||||
result = evaluate(good_criteria)
|
||||
assert result.stars is not None
|
||||
assert result.stars >= 4 # Good results should get 4-5 stars
|
||||
|
||||
def test_poor_results_low_stars(self, poor_criteria):
|
||||
result = evaluate(poor_criteria)
|
||||
assert result.stars is not None
|
||||
assert result.stars <= 2
|
||||
|
||||
def test_result_has_region_scores(self, good_criteria):
|
||||
result = evaluate(good_criteria)
|
||||
assert len(result.region_scores) > 0
|
||||
|
||||
def test_result_has_colors(self, good_criteria):
|
||||
result = evaluate(good_criteria)
|
||||
for rs in result.region_scores:
|
||||
assert rs.color is not None
|
||||
|
||||
def test_result_summary(self, good_criteria):
|
||||
result = evaluate(good_criteria)
|
||||
summary = result.summary()
|
||||
assert "Euro NCAP" in summary
|
||||
assert "stars" in summary
|
||||
|
||||
def test_protocol_name(self):
|
||||
scorer = EuroNCAP()
|
||||
assert scorer.protocol_name == "Euro NCAP"
|
||||
Reference in New Issue
Block a user