mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-27 23:35:01 +00:00
Record a failure when the selection yields no export rows 🟥
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
5ee8b2df50
commit
4220ce4bf0
1 changed files with 27 additions and 0 deletions
|
|
@ -11,6 +11,7 @@ from moto import mock_aws
|
|||
from openpyxl import load_workbook
|
||||
|
||||
from domain.scenario_export.scenario_sheet import ExportMeasure, PropertyScenarioData
|
||||
from domain.tasks.subtasks import SubTaskFailure
|
||||
from infrastructure.s3.s3_client import S3Client
|
||||
from orchestration.scenario_export_orchestrator import ScenarioExportOrchestrator
|
||||
from tests.infrastructure import make_boto_client
|
||||
|
|
@ -155,3 +156,29 @@ def test_an_email_failure_does_not_lose_the_built_export(exports: S3Client) -> N
|
|||
# on sub_task.outputs, so the link isn't lost).
|
||||
assert result.presigned_url
|
||||
assert exports.get_object(result.export_s3_key)
|
||||
|
||||
|
||||
def test_a_selection_that_yields_no_rows_is_a_recorded_failure(
|
||||
exports: S3Client,
|
||||
) -> None:
|
||||
# arrange — no property has a default Plan under the scenario (model A), so
|
||||
# the repo returns no rows for it.
|
||||
email = _RecordingEmail()
|
||||
orchestrator = ScenarioExportOrchestrator(
|
||||
rows=_FakeRows({}),
|
||||
scenarios=_FakeScenarioNames({5: "Fabric first"}),
|
||||
exports=exports,
|
||||
email=email,
|
||||
url_ttl_seconds=3600,
|
||||
)
|
||||
|
||||
# act / assert — a recorded failure, never an empty workbook emailed.
|
||||
with pytest.raises(SubTaskFailure):
|
||||
orchestrator.run(
|
||||
portfolio_id=100,
|
||||
scenario_ids=[5],
|
||||
property_ids=[1],
|
||||
recipient_email="user@example.com",
|
||||
export_name="portfolio-100",
|
||||
)
|
||||
assert email.sent == []
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue