added RAG, Multiuser, TG bot

This commit is contained in:
2026-06-13 20:20:56 +00:00
parent 66e1b0e29e
commit c8a9429bed
142 changed files with 19901 additions and 8790 deletions
+102
View File
@@ -0,0 +1,102 @@
import pytest
from app.fitness.body_composition import (
compute_body_composition,
ffmi,
lean_body_mass,
navy_body_fat_pct,
whr,
)
def test_navy_male_reasonable_range():
bf = navy_body_fat_pct(
sex="male",
height_cm=180,
neck_cm=38,
waist_cm=84,
)
assert bf is not None
assert 5 <= bf <= 35
def test_navy_female_requires_hip():
assert navy_body_fat_pct(
sex="female",
height_cm=165,
neck_cm=34,
waist_cm=72,
hip_cm=None,
) is None
bf = navy_body_fat_pct(
sex="female",
height_cm=165,
neck_cm=34,
waist_cm=72,
hip_cm=98,
)
assert bf is not None
assert 10 <= bf <= 45
def test_navy_invalid_waist_neck():
assert navy_body_fat_pct(
sex="male",
height_cm=180,
neck_cm=40,
waist_cm=39,
) is None
def test_whr():
assert whr(80, 100) == 0.8
def test_lean_body_mass_and_ffmi():
lbm = lean_body_mass(80, 20)
assert lbm == 64.0
score = ffmi(80, 180, 20)
assert score is not None
assert 15 <= score <= 25
def test_compute_manual_body_fat():
result = compute_body_composition(
sex="male",
height_cm=180,
weight_kg=80,
body_fat_pct=18,
waist_cm=84,
hip_cm=100,
)
assert result["body_fat_pct"] == 18.0
assert result["body_fat_method"] == "manual"
assert result["whr"] == 0.84
assert result["lbm_kg"] == 65.6
assert result["ffmi"] is not None
def test_compute_navy_auto():
result = compute_body_composition(
sex="male",
height_cm=180,
weight_kg=82,
neck_cm=38,
waist_cm=84,
)
assert result["body_fat_pct"] is not None
assert result["body_fat_method"] == "navy"
assert result["lbm_kg"] is not None
def test_compute_female_warning_without_hip():
result = compute_body_composition(
sex="female",
height_cm=165,
weight_kg=60,
neck_cm=34,
waist_cm=72,
)
assert result["body_fat_pct"] is None
assert any("бёдер" in w for w in result["warnings"])