"""Tests for coefficient calculation. Verified against Приложение 28.1 к ГЭСН 81-02-28-2020 (rccs.ru PDF). """ import pytest from smeta_railway.calc.coefficients import get_coefficients class TestCoefficients: """Test coefficient calculation for various norm codes.""" def test_037_okno_151(self): """28-01-037-02 (замена рельсов): К_окно = 1.51, not 1.81.""" c = get_coefficients("ГЭСН 28-01-037-02") # ЗТ = dvizhenie(1.40) * vl(1.20) = 1.68 assert c.zt == pytest.approx(1.40 * 1.20, rel=1e-3) # ЭМ = dvizhenie(1.40) * vl(1.20) * okno(1.51) = 2.5368 assert c.em == pytest.approx(1.40 * 1.20 * 1.51, rel=1e-3) assert set(c.applied) == {"dvizhenie", "vl", "okno"} def test_068_okno_181(self): """28-01-068-07 (глубокая очистка ЩОМ): К_окно = 1.81.""" c = get_coefficients("ГЭСН 28-01-068-07") # ЗТ = dvizhenie(1.40) * vl(1.20) = 1.68 assert c.zt == pytest.approx(1.40 * 1.20, rel=1e-3) # ЭМ = dvizhenie(1.40) * vl(1.20) * okno(1.81) = 3.0408 assert c.em == pytest.approx(1.40 * 1.20 * 1.81, rel=1e-3) assert len(c.applied) == 3 def test_031_okno_181(self): """28-01-031-01 (выправка ВПО): К_окно = 1.81.""" c = get_coefficients("ГЭСН 28-01-031-01") assert c.em == pytest.approx(1.40 * 1.20 * 1.81, rel=1e-3) def test_no_okno_155(self): """28-01-155-01: manual work, excluded from okno.""" c = get_coefficients("ГЭСН 28-01-155-01") # ЗТ = dvizhenie(1.40) * vl(1.20) = 1.68 assert c.zt == pytest.approx(1.40 * 1.20, rel=1e-3) # ЭМ = dvizhenie(1.40) * vl(1.20) = 1.68 (no okno) assert c.em == pytest.approx(1.40 * 1.20, rel=1e-3) assert "okno" not in c.applied def test_no_okno_043(self): """28-01-043-01: rail cutting, excluded from okno.""" c = get_coefficients("ГЭСН 28-01-043-01") assert "okno" not in c.applied assert c.em == pytest.approx(1.40 * 1.20, rel=1e-3) def test_no_okno_044(self): """28-01-044-01: insulating joints, excluded from okno.""" c = get_coefficients("ГЭСН 28-01-044-01") assert "okno" not in c.applied def test_earthwork_no_coefficients(self): """01-02-057-02: earthwork, no collection 28 coefficients.""" c = get_coefficients("ГЭСН 01-02-057-02") assert c.zt == 1.0 assert c.em == 1.0 assert c.ztm == 1.0 assert c.applied == [] def test_vl_applies_to_zt(self): """К_ВЛ (п.1.2) applies to BOTH ЗТ and ЭМ per Приложение 28.1.""" c = get_coefficients("ГЭСН 28-01-155-01") # no okno # ЗТ should include vl: 1.40 * 1.20 = 1.68 assert c.zt == pytest.approx(1.68, rel=1e-3) assert "vl" in c.applied def test_formulas_display(self): """Check formula strings for display.""" c = get_coefficients("ГЭСН 28-01-037-02") assert "1.40" in c.formulas["zt"] assert "1.20" in c.formulas["zt"] assert "1.51" in c.formulas["em"] # okno = 1.51 for 037 def test_041_svarka_okno_181(self): """28-01-041-01 (сварка ПРСМ): К_окно = 1.81.""" c = get_coefficients("ГЭСН 28-01-041-01") assert c.em == pytest.approx(1.40 * 1.20 * 1.81, rel=1e-3) assert "okno" in c.applied