"""Суточные итоги на голову (parity Excel Рацион КРС).""" from app.lab.calc.engine import calculate_ration def test_daily_total_scales_by_heads(): lines = [ { "daily_kg": 141, "in_ration": True, "in_compound": False, "dry_matter": 880, "nutrients": {}, } ] herd = calculate_ration("BEEF", lines, {}, heads_per_trip=141) per_head = calculate_ration("BEEF", [{**lines[0], "daily_kg": 1}], {}, heads_per_trip=1) herd_dm = next(i["content"] for i in herd["indicators"] if i["label"] == "Сухое вещество") head_dm = next(i["content"] for i in per_head["indicators"] if i["label"] == "Сухое вещество") assert herd_dm == head_dm == 880 def test_sv_from_nutrients_overrides_legacy_percent(): result = calculate_ration( "BEEF", [ { "daily_kg": 10, "in_ration": True, "in_compound": False, "dry_matter": 56, "nutrients": {"СВ": 880}, } ], {}, ) dm = next(i["content"] for i in result["indicators"] if i["label"] == "Сухое вещество") assert dm == 8800