mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-30 13:10:47 +00:00
Expose an off-peak meter's standing charge and full day/night blend range 🟩
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
af2e8b3843
commit
bda8a3f276
2 changed files with 38 additions and 0 deletions
|
|
@ -69,6 +69,10 @@ class FuelRates:
|
|||
return self._rate(fuel).unit_rate_p_per_kwh
|
||||
|
||||
def standing_charge_p_per_day(self, fuel: Fuel) -> float:
|
||||
if fuel is Fuel.ELECTRICITY_OFF_PEAK:
|
||||
if self.off_peak is None:
|
||||
raise UnpricedFuel(fuel)
|
||||
return self.off_peak.standing_charge_p_per_day
|
||||
return self._rate(fuel).standing_charge_p_per_day
|
||||
|
||||
def _rate(self, fuel: Fuel) -> FuelRate:
|
||||
|
|
|
|||
|
|
@ -36,6 +36,40 @@ def test_off_peak_blended_rate_at_zero_high_fraction_is_the_night_rate() -> None
|
|||
assert blended == 13.89
|
||||
|
||||
|
||||
def test_off_peak_blended_rate_at_full_high_fraction_is_the_day_rate() -> None:
|
||||
# Arrange — an all-day load (high-rate fraction 1.0).
|
||||
rates = _off_peak_rates()
|
||||
|
||||
# Act / Assert — every kWh bills at the dearer day rate.
|
||||
assert rates.off_peak_blended_p_per_kwh(high_rate_fraction=1.0) == 29.73
|
||||
|
||||
|
||||
def test_off_peak_blended_rate_blends_day_and_night_linearly() -> None:
|
||||
# Arrange — 25% of the load at the day rate, 75% at night.
|
||||
rates = _off_peak_rates()
|
||||
|
||||
# Act / Assert — 0.25 * 29.73 + 0.75 * 13.89 = 17.85
|
||||
assert rates.off_peak_blended_p_per_kwh(high_rate_fraction=0.25) == pytest.approx(17.85)
|
||||
|
||||
|
||||
def test_off_peak_blend_without_a_snapshot_off_peak_entry_raises_unpriced_fuel() -> None:
|
||||
# Arrange — a snapshot that carries no off-peak entry at all.
|
||||
rates = _rates()
|
||||
|
||||
# Act / Assert
|
||||
with pytest.raises(UnpricedFuel) as excinfo:
|
||||
rates.off_peak_blended_p_per_kwh(high_rate_fraction=0.5)
|
||||
assert excinfo.value.fuel is Fuel.ELECTRICITY_OFF_PEAK
|
||||
|
||||
|
||||
def test_off_peak_meter_standing_charge_reads_back() -> None:
|
||||
# Arrange — the bill adds the off-peak meter's standing charge once per meter.
|
||||
rates = _off_peak_rates()
|
||||
|
||||
# Act / Assert
|
||||
assert rates.standing_charge_p_per_day(Fuel.ELECTRICITY_OFF_PEAK) == 56.99
|
||||
|
||||
|
||||
def test_unit_rate_and_standing_charge_read_back_for_a_priced_fuel() -> None:
|
||||
# Arrange
|
||||
rates = _rates()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue