From 3a76bd0f7c0e7399486bb50131bd97206e71a99d Mon Sep 17 00:00:00 2001 From: Daniel Roth Date: Wed, 15 Jul 2026 09:35:01 +0000 Subject: [PATCH] =?UTF-8?q?Use=20the=20fetched=20gov=20cert=20when=20nothi?= =?UTF-8?q?ng=20is=20stored=20=F0=9F=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 (1M context) --- tests/applications/modelling_e2e/test_handler.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/applications/modelling_e2e/test_handler.py b/tests/applications/modelling_e2e/test_handler.py index 18a887864..eb3e943c6 100644 --- a/tests/applications/modelling_e2e/test_handler.py +++ b/tests/applications/modelling_e2e/test_handler.py @@ -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."""