mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
Slice 3/6 of the postcode_splitter refactor (Hestia-Homes/Model#1101). Introduces a thin typed infrastructure layer wrapping boto3 for the AWS side of the splitter. S3Client/SqsClient are bucket-/queue-bound byte adapters; CsvS3Client subclasses S3Client to round-trip CSV row dicts via the existing parse_s3_uri helper in utils/s3.py; Address2UprnQueueClient subclasses SqsClient to publish the typed {task_id, sub_task_id, s3_uri} fan-out body the downstream consumer expects. moto[s3,sqs] is pulled into test.requirements.txt and the new tests/infrastructure/ suite exercises each client against the moto backend (S3 round-trip, CSV round-trip, SQS send + body inspection, typed publish + body inspection). pyright --strict is clean on the new modules. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
32 lines
949 B
Python
32 lines
949 B
Python
import os
|
|
from collections.abc import Iterator
|
|
from typing import Optional
|
|
|
|
import pytest
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def _aws_creds() -> Iterator[None]: # pyright: ignore[reportUnusedFunction]
|
|
"""Stub AWS creds so botocore doesn't probe the host environment.
|
|
|
|
Applied automatically to every test in ``tests/infrastructure/``.
|
|
"""
|
|
keys = (
|
|
"AWS_ACCESS_KEY_ID",
|
|
"AWS_SECRET_ACCESS_KEY",
|
|
"AWS_SESSION_TOKEN",
|
|
"AWS_DEFAULT_REGION",
|
|
)
|
|
prev: dict[str, Optional[str]] = {k: os.environ.get(k) for k in keys}
|
|
os.environ["AWS_ACCESS_KEY_ID"] = "testing"
|
|
os.environ["AWS_SECRET_ACCESS_KEY"] = "testing"
|
|
os.environ["AWS_SESSION_TOKEN"] = "testing"
|
|
os.environ["AWS_DEFAULT_REGION"] = "us-east-1"
|
|
try:
|
|
yield
|
|
finally:
|
|
for k, v in prev.items():
|
|
if v is None:
|
|
os.environ.pop(k, None)
|
|
else:
|
|
os.environ[k] = v
|