Files
duocthu/apps/ai-service/tests/test_calculators.py
T

22 lines
683 B
Python

import pytest
from rag.calculators import body_surface_area_m2
def test_bsa_matches_book_worked_example():
# Dược thư Phụ lục 1: "165 cm và 60 kg sẽ có diện tích 1,66 m²".
assert round(body_surface_area_m2(60, 165), 2) == 1.66
def test_bsa_matches_book_table_cells():
# Independent cells read from the BSA table (printed 1499): ground truth.
assert round(body_surface_area_m2(10, 90), 2) == 0.50
assert round(body_surface_area_m2(70, 170), 2) == 1.81
def test_bsa_rejects_nonpositive_inputs():
with pytest.raises(ValueError):
body_surface_area_m2(0, 165)
with pytest.raises(ValueError):
body_surface_area_m2(60, -1)