mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-30 13:10:47 +00:00
Merge pull request #1280 from Hestia-Homes/feature/modelling-e2e-failure-logs
Mark unmappable cohort certs as a modelling_e2e subtask failure
This commit is contained in:
commit
09ec985f98
1 changed files with 18 additions and 18 deletions
|
|
@ -214,16 +214,19 @@ def test_lodged_epc_path_saves_epc_plan_and_marks_modelled(
|
||||||
_baseline_orchestrator.return_value.run.assert_called_once_with([PROPERTY_ID])
|
_baseline_orchestrator.return_value.run.assert_called_once_with([PROPERTY_ID])
|
||||||
|
|
||||||
|
|
||||||
def test_skipped_cohort_certs_are_surfaced_in_the_outputs() -> None:
|
def test_skipped_cohort_certs_fail_the_subtask_but_the_plan_is_still_saved() -> None:
|
||||||
"""Cohort certs the mapper can't consume are skipped (so prediction is not
|
"""Cohort certs the mapper can't consume are skipped (so prediction is not
|
||||||
aborted) and surfaced — with cert numbers — in the subtask outputs, so the
|
aborted), then surfaced as a failure — the subtask is marked failed (the
|
||||||
mapper gaps can be reported and closed."""
|
cert numbers land in outputs.error via the raised RuntimeError) so the
|
||||||
|
mapper gaps get debugged. The batch still ran to completion first, so the
|
||||||
|
property's plan was committed before the handler raised."""
|
||||||
from repositories.comparable_properties.epc_comparable_properties_repository import (
|
from repositories.comparable_properties.epc_comparable_properties_repository import (
|
||||||
SkippedCohortCert,
|
SkippedCohortCert,
|
||||||
)
|
)
|
||||||
|
|
||||||
mock_engine = _engine_mock([PROPERTY_ID], [UPRN], [POSTCODE])
|
mock_engine = _engine_mock([PROPERTY_ID], [UPRN], [POSTCODE])
|
||||||
mock_plan = _plan_mock()
|
mock_plan = _plan_mock()
|
||||||
|
mock_uow = MagicMock()
|
||||||
skipped = [
|
skipped = [
|
||||||
SkippedCohortCert(
|
SkippedCohortCert(
|
||||||
certificate_number="8257-7539-1649-0633-4992",
|
certificate_number="8257-7539-1649-0633-4992",
|
||||||
|
|
@ -287,24 +290,21 @@ def test_skipped_cohort_certs_are_surfaced_in_the_outputs() -> None:
|
||||||
MockUoW = stack.enter_context(
|
MockUoW = stack.enter_context(
|
||||||
patch("applications.modelling_e2e.handler.PostgresUnitOfWork")
|
patch("applications.modelling_e2e.handler.PostgresUnitOfWork")
|
||||||
)
|
)
|
||||||
MockUoW.return_value.__enter__.return_value = MagicMock()
|
MockUoW.return_value.__enter__.return_value = mock_uow
|
||||||
MockUoW.return_value.__exit__.return_value = False
|
MockUoW.return_value.__exit__.return_value = False
|
||||||
|
|
||||||
# Act
|
# Act — the skipped cert fails the subtask, but only after the batch ran.
|
||||||
result = _call_handler(_BODY)
|
with pytest.raises(RuntimeError) as excinfo:
|
||||||
|
_call_handler(_BODY)
|
||||||
|
|
||||||
# Assert — the handler's return (→ subtask outputs.result) carries the cert
|
# Assert — the cert number + error reach outputs.error (the raised message),
|
||||||
# numbers + errors of every skipped cohort cert.
|
# and the property's plan was still committed before the handler raised.
|
||||||
assert result == {
|
message = str(excinfo.value)
|
||||||
"skipped_unmappable_cohort_certs": [
|
assert "skipped_unmappable_cohort_certs" in message
|
||||||
{
|
assert "8257-7539-1649-0633-4992" in message
|
||||||
"certificate_number": "8257-7539-1649-0633-4992",
|
assert "RdSapSchema17_1: missing required field 'window'" in message
|
||||||
"error": (
|
mock_uow.plan.save.assert_called_once()
|
||||||
"ValueError: RdSapSchema17_1: missing required field 'window'"
|
mock_uow.commit.assert_called_once()
|
||||||
),
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue