mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
Aligns the composition with its entry point (the `ara_first_run` lambda + `AraFirstRunTriggerBody`): clearer what the file does. - orchestration/first_run_pipeline.py → ara_first_run_pipeline.py - FirstRunPipeline → AraFirstRunPipeline; FirstRunCommand → AraFirstRunCommand - test files renamed to match Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
44 lines
1.5 KiB
Python
44 lines
1.5 KiB
Python
from __future__ import annotations
|
|
|
|
from typing import Optional
|
|
from uuid import UUID
|
|
|
|
from applications.ara_first_run.ara_first_run_trigger_body import (
|
|
AraFirstRunTriggerBody,
|
|
)
|
|
from applications.ara_first_run.handler import dispatch_first_run
|
|
from orchestration.ara_first_run_pipeline import AraFirstRunCommand
|
|
|
|
|
|
class _SpyPipeline:
|
|
"""Records the command it is asked to run, instead of composing stages."""
|
|
|
|
def __init__(self) -> None:
|
|
self.received: Optional[AraFirstRunCommand] = None
|
|
|
|
def run(self, command: AraFirstRunCommand) -> None:
|
|
self.received = command
|
|
|
|
|
|
def test_validates_the_event_body_and_delegates_the_command_to_the_pipeline() -> None:
|
|
# Arrange — a raw SQS body, as the decorator hands it to the handler.
|
|
body = {
|
|
"task_id": "e295d89b-a7c5-4a9a-8b4e-b405fab1f298",
|
|
"sub_task_id": "f4a9944f-41f0-4a33-8669-5016ec574068",
|
|
"portfolio_id": 42,
|
|
"property_ids": [101, 102],
|
|
"scenario_ids": [7],
|
|
}
|
|
pipeline = _SpyPipeline()
|
|
|
|
# Act
|
|
dispatch_first_run(body, pipeline=pipeline)
|
|
|
|
# Assert — the raw body was validated into the typed trigger and handed
|
|
# straight on, untouched.
|
|
received = pipeline.received
|
|
assert isinstance(received, AraFirstRunTriggerBody)
|
|
assert received.task_id == UUID("e295d89b-a7c5-4a9a-8b4e-b405fab1f298")
|
|
assert received.portfolio_id == 42
|
|
assert received.property_ids == [101, 102]
|
|
assert received.scenario_ids == [7]
|