"""Tests for coefficient calculation.""" import pytest from smeta_railway.calc.coefficients import get_coefficients class TestCoefficients: """Test coefficient calculation for various norm codes.""" def test_full_coefficients_037(self): """28-01-037-02: all 3 coefficients applied.""" c = get_coefficients("ГЭСН 28-01-037-02") assert c.zt == 1.60 assert c.em == pytest.approx(1.60 * 1.20 * 1.81, rel=1e-3) assert c.ztm == pytest.approx(1.60 * 1.20 * 1.81, rel=1e-3) assert set(c.applied) == {"dvizhenie", "vl", "okno"} def test_full_coefficients_068(self): """28-01-068-07: all 3 coefficients (machine norm).""" c = get_coefficients("ГЭСН 28-01-068-07") assert c.zt == 1.60 assert c.em == pytest.approx(3.4752, rel=1e-3) assert len(c.applied) == 3 def test_no_okno_155(self): """28-01-155-01: manual work, no okno coefficient.""" c = get_coefficients("ГЭСН 28-01-155-01") assert c.zt == 1.60 assert c.em == pytest.approx(1.60 * 1.20, rel=1e-3) assert c.ztm == pytest.approx(1.60 * 1.20, rel=1e-3) assert "okno" not in c.applied assert "dvizhenie" in c.applied assert "vl" in c.applied def test_no_okno_043(self): """28-01-043-01: rail cutting, no okno.""" c = get_coefficients("ГЭСН 28-01-043-01") assert "okno" not in c.applied assert c.em == pytest.approx(1.92, rel=1e-3) def test_no_okno_044(self): """28-01-044-01: insulating joints, no 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_formulas_display(self): """Check formula strings for display.""" c = get_coefficients("ГЭСН 28-01-037-02") assert "1.60" in c.formulas["zt"] assert "1.20" in c.formulas["em"] assert "1.81" in c.formulas["em"] def test_zt_only_dvizhenie(self): """ZT gets only dvizhenie (not vl, not okno).""" c = get_coefficients("ГЭСН 28-01-037-02") assert c.zt == 1.60 # only dvizhenie def test_em_value(self): """EM = 1.60 * 1.20 * 1.81 = 3.4752.""" c = get_coefficients("ГЭСН 28-01-037-02") assert c.em == pytest.approx(3.4752, rel=1e-4)