Files
smeta-railway/tests/test_coefficients.py
T
anorandClaude Opus 4.6 897d2d1b76 refactor: декомпозиция монолита в пакет smeta-railway
- Пакетная структура src/smeta_railway/ с модулями calc/, data/, output/
- Pydantic-конфиг: всё через YAML, сметчик не трогает Python
- EstimateCalculator: ядро расчёта, параметризованные коэффициенты
- FGISLookup: pickle cache (4.7с → ~50мс при повторном запуске)
- CLI: smeta generate/fetch-resources/validate (typer)
- 28 тестов (coefficients, overhead, fgis, estimate)
- Исправлен баг: НР/СП для земляных работ (92%/46% вместо 109%/65%)
- ПЗ совпадают бит-в-бит со старым генератором

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 18:42:19 +10:00

71 lines
2.6 KiB
Python

"""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)