mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
Slice 1 of Bill Derivation — the reference-data foundation that later slices price the calculator's per-end-use kWh against: - Fuel enum (canonical billing fuels; the join key between the calculator's SAP-code fuels and the rates snapshot). COAL + HEAT_NETWORK are members with no national rate. - FuelRates value object: unit_rate_p_per_kwh / standing_charge_p_per_day / seg_export_p_per_kwh; raises UnpricedFuel on a fuel it has no rate for rather than billing at a wrong default. - FuelRatesRepository port (ADR-0011 Repo-reads-stored-reference-data) + StaticFileFuelRatesRepository reading a committed JSON snapshot. - Snapshot fuel_rates_2026_q2.json: GB national, Apr-Jun 2026 Ofgem cap (gas/electricity) + DESNZ/NEP May 2026 (off-gas). Carries the full researched data; the value object exposes single-rate fuels this slice. Off-peak (day/night), house coal and heat network raise UnpricedFuel until later slices. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
33 lines
1,003 B
Python
33 lines
1,003 B
Python
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
from domain.fuel_rates.fuel import Fuel, UnpricedFuel
|
|
from domain.fuel_rates.fuel_rates import FuelRate, FuelRates
|
|
|
|
|
|
def _rates() -> FuelRates:
|
|
return FuelRates(
|
|
period="test",
|
|
seg_export_p_per_kwh=15.0,
|
|
rates={Fuel.MAINS_GAS: FuelRate(unit_rate_p_per_kwh=5.74, standing_charge_p_per_day=29.09)},
|
|
)
|
|
|
|
|
|
def test_unit_rate_and_standing_charge_read_back_for_a_priced_fuel() -> None:
|
|
# Arrange
|
|
rates = _rates()
|
|
|
|
# Act / Assert
|
|
assert rates.unit_rate_p_per_kwh(Fuel.MAINS_GAS) == 5.74
|
|
assert rates.standing_charge_p_per_day(Fuel.MAINS_GAS) == 29.09
|
|
|
|
|
|
def test_a_fuel_absent_from_the_snapshot_raises_unpriced_fuel() -> None:
|
|
# Arrange — LPG is not in this snapshot.
|
|
rates = _rates()
|
|
|
|
# Act / Assert — the raise carries the offending fuel for the operator.
|
|
with pytest.raises(UnpricedFuel) as excinfo:
|
|
rates.unit_rate_p_per_kwh(Fuel.LPG)
|
|
assert excinfo.value.fuel is Fuel.LPG
|