"""Tests for overhead calculation.""" import pytest from smeta_railway.calc.overhead import calc_overhead, get_overhead_percents class TestOverhead: def test_railway_percents(self): nr_pct, sp_pct, *_ = get_overhead_percents("ГЭСН 28-01-037-02") assert nr_pct == 109 assert sp_pct == 65 def test_earthwork_percents(self): nr_pct, sp_pct, *_ = get_overhead_percents("ГЭСН 01-02-057-02") assert nr_pct == 92 assert sp_pct == 46 def test_calc_overhead(self): fot = 100_000.0 nr, sp = calc_overhead(fot, 109, 65) assert nr == 109_000.0 assert sp == 65_000.0 def test_calc_overhead_rounding(self): fot = 12345.67 nr, sp = calc_overhead(fot, 109, 65) assert nr == pytest.approx(13456.78, abs=0.01) assert sp == pytest.approx(8024.69, abs=0.01) def test_railway_labels(self): _, _, nr_code, nr_label, sp_code, sp_label = get_overhead_percents("ГЭСН 28-01-031-01") assert "812" in nr_code assert "774" in sp_code assert "Железные дороги" in nr_label