Use the fetched gov cert when nothing is stored 🟥

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Daniel Roth 2026-07-15 09:35:01 +00:00
parent dd1ea99c3d
commit 3a76bd0f7c

View file

@ -1458,6 +1458,21 @@ def test_gov_cert_newer_than_stored_survey_wins_and_is_flagged_for_saving() -> N
assert chosen_is_fetched is True
def test_gov_cert_is_used_when_nothing_is_stored() -> None:
"""Only the gov cert exists: it is the assessment, and it must be persisted."""
# Arrange
from applications.modelling_e2e.handler import _newer_lodged
fetched = _lodged_epc("2023-12-01")
# Act
chosen, chosen_is_fetched = _newer_lodged(None, 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."""