mirror of
https://github.com/BigBodyCobain/Shadowbroker.git
synced 2026-08-29 13:40:38 +02:00
v0.9.5: The Voltron Update — modular architecture, stable IDs, parallelized boot
- Parallelized startup (60s → 15s) via ThreadPoolExecutor - Adaptive polling engine with ETag caching (no more bbox interrupts) - useCallback optimization for interpolation functions - Sliding LAYERS/INTEL edge panels replace bulky Record Panel - Modular fetcher architecture (flights, geo, infrastructure, financial, earth_observation) - Stable entity IDs for GDELT & News popups (PR #63, credit @csysp) - Admin auth (X-Admin-Key), rate limiting (slowapi), auto-updater - Docker Swarm secrets support, env_check.py validation - 85+ vitest tests, CI pipeline, geoJSON builder extraction - Server-side viewport bbox filtering reduces payloads 80%+ Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Former-commit-id: f2883150b5bc78ebc139d89cc966a76f7d7c0408
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
60c90661d4
commit
90c2e90e2c
@@ -0,0 +1,72 @@
|
||||
"""Tests for Pydantic response schemas."""
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
from services.schemas import HealthResponse, RefreshResponse, AisFeedResponse, RouteResponse
|
||||
|
||||
|
||||
class TestHealthResponse:
|
||||
def test_valid_health_response(self):
|
||||
data = {
|
||||
"status": "ok",
|
||||
"last_updated": "2024-01-01T00:00:00",
|
||||
"sources": {"flights": 150, "ships": 42},
|
||||
"freshness": {"flights": "2024-01-01T00:00:00", "ships": "2024-01-01T00:00:00"},
|
||||
"uptime_seconds": 3600
|
||||
}
|
||||
resp = HealthResponse(**data)
|
||||
assert resp.status == "ok"
|
||||
assert resp.sources["flights"] == 150
|
||||
assert resp.uptime_seconds == 3600
|
||||
|
||||
def test_health_response_optional_last_updated(self):
|
||||
data = {
|
||||
"status": "ok",
|
||||
"sources": {},
|
||||
"freshness": {},
|
||||
"uptime_seconds": 0
|
||||
}
|
||||
resp = HealthResponse(**data)
|
||||
assert resp.last_updated is None
|
||||
|
||||
def test_health_response_missing_required_field(self):
|
||||
with pytest.raises(ValidationError):
|
||||
HealthResponse(status="ok") # Missing sources, freshness, uptime_seconds
|
||||
|
||||
|
||||
class TestRefreshResponse:
|
||||
def test_valid_refresh(self):
|
||||
resp = RefreshResponse(status="refreshing")
|
||||
assert resp.status == "refreshing"
|
||||
|
||||
def test_missing_status(self):
|
||||
with pytest.raises(ValidationError):
|
||||
RefreshResponse()
|
||||
|
||||
|
||||
class TestAisFeedResponse:
|
||||
def test_valid_ais_feed(self):
|
||||
resp = AisFeedResponse(status="ok", ingested=42)
|
||||
assert resp.ingested == 42
|
||||
|
||||
def test_default_ingested_zero(self):
|
||||
resp = AisFeedResponse(status="ok")
|
||||
assert resp.ingested == 0
|
||||
|
||||
|
||||
class TestRouteResponse:
|
||||
def test_valid_route(self):
|
||||
resp = RouteResponse(
|
||||
orig_loc=[40.6413, -73.7781],
|
||||
dest_loc=[51.4700, -0.4543],
|
||||
origin_name="JFK",
|
||||
dest_name="LHR"
|
||||
)
|
||||
assert resp.origin_name == "JFK"
|
||||
assert len(resp.orig_loc) == 2
|
||||
|
||||
def test_all_optional(self):
|
||||
resp = RouteResponse()
|
||||
assert resp.orig_loc is None
|
||||
assert resp.dest_loc is None
|
||||
assert resp.origin_name is None
|
||||
assert resp.dest_name is None
|
||||
Reference in New Issue
Block a user