Use the fetched gov cert when it is the newer assessment 🟥

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Daniel Roth 2026-07-15 09:33:28 +00:00
parent ec584fc84c
commit 22bd0eadbe

View file

@ -1442,6 +1442,22 @@ def test_stored_survey_newer_than_gov_cert_wins_the_tie_break() -> None:
assert chosen_is_fetched is False
def test_gov_cert_newer_than_stored_survey_wins_and_is_flagged_for_saving() -> None:
"""A genuinely fresher gov cert still wins, and is flagged new so it persists."""
# Arrange
from applications.modelling_e2e.handler import _newer_lodged
stored = _lodged_epc("2023-12-01")
fetched = _lodged_epc("2026-05-01")
# Act
chosen, chosen_is_fetched = _newer_lodged(stored, fetched)
# Assert
assert chosen is fetched
assert chosen_is_fetched is True
def test_refetch_epc_false_with_stored_epc_skips_api_call() -> None:
"""refetch_epc=False + stored lodged EPC present: EpcClientService.get_by_uprn
is never called; the stored EPC is used and reaches run_modelling."""