mirror of
https://github.com/azaion/gps-denied-onboard.git
synced 2026-06-21 10:21:13 +00:00
[AZ-319] C11 HttpTileUploader (post-landing upload path)
Lands the production HttpTileUploader composing AZ-317's gate, AZ-318's per-flight signing, and consumer-side cuts over c6 storage. Implements the full upload flow: gate ON_GROUND -> start_session -> enumerate pending -> per-batch multipart POST with Ed25519 signing -> mark_uploaded on ack -> end_session in finally. Honours Retry-After (RFC 7231 int + HTTP-date), exponential backoff on 5xx, fail-fast on TLS/401/403. Adds C11Config block, three FDR kinds (tile.queued, tile.rejected, batch.complete), and the build_tile_uploader composition-root factory. Cross-component access to c6 stays Protocol-cut (AZ-507 / AZ-270). Tests: 17 new unit tests covering AC-1..AC-14 plus throughput NFR; AZ-272 schema fixtures for the three new FDR kinds. Full unit suite: 1404 passed. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
"""AZ-319 AC-12 — `HttpTileUploader` satisfies the `TileUploader` Protocol.
|
||||
|
||||
Smoke-test that the concrete impl exposes every method the Protocol
|
||||
requires (positive case) and that a partial fake omitting one of the
|
||||
three required methods is correctly rejected (negative case).
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
import httpx
|
||||
|
||||
from gps_denied_onboard.components.c11_tile_manager import (
|
||||
C11Config,
|
||||
HttpTileUploader,
|
||||
)
|
||||
from gps_denied_onboard.components.c11_tile_manager.interface import TileUploader
|
||||
from gps_denied_onboard.fdr_client.fakes import FakeFdrSink
|
||||
|
||||
_PRODUCER_ID = "c11_tile_manager.tile_uploader"
|
||||
|
||||
|
||||
class _NullSleep:
|
||||
def __call__(self, _seconds: float) -> None:
|
||||
return None
|
||||
|
||||
|
||||
class _PartialFakeMissingConfirm:
|
||||
"""Conformance counterexample: missing ``confirm_flight_state``."""
|
||||
|
||||
def upload_pending_tiles(self, request: object) -> object: # noqa: ARG002
|
||||
return None
|
||||
|
||||
def enumerate_pending_tiles(
|
||||
self, flight_id: object | None = None
|
||||
) -> list[object]: # noqa: ARG002
|
||||
return []
|
||||
|
||||
|
||||
def test_ac12_concrete_uploader_satisfies_protocol() -> None:
|
||||
# Arrange — supply minimal-yet-valid dependencies; the Protocol
|
||||
# check only inspects method names, not their behaviour.
|
||||
cfg = C11Config(
|
||||
satellite_provider_ingest_url="https://parent-suite.test",
|
||||
upload_batch_size=10,
|
||||
upload_http_timeout_s=5.0,
|
||||
upload_max_retry_after_s=600,
|
||||
companion_id="conformance",
|
||||
)
|
||||
transport = httpx.MockTransport(lambda r: httpx.Response(202))
|
||||
uploader = HttpTileUploader(
|
||||
http_client=httpx.Client(transport=transport),
|
||||
tile_store=object(), # type: ignore[arg-type]
|
||||
tile_metadata_store=object(), # type: ignore[arg-type]
|
||||
flight_state_gate=object(), # type: ignore[arg-type]
|
||||
key_manager=object(), # type: ignore[arg-type]
|
||||
fdr_client=FakeFdrSink(_PRODUCER_ID), # type: ignore[arg-type]
|
||||
logger=logging.getLogger("test_az319_conformance"),
|
||||
config=cfg,
|
||||
sleep=_NullSleep(),
|
||||
)
|
||||
|
||||
# Assert
|
||||
assert isinstance(uploader, TileUploader)
|
||||
|
||||
|
||||
def test_ac12_partial_fake_is_not_protocol_conformant() -> None:
|
||||
# Assert
|
||||
assert not isinstance(_PartialFakeMissingConfirm(), TileUploader)
|
||||
Reference in New Issue
Block a user