mirror of
https://github.com/BigBodyCobain/Shadowbroker.git
synced 2026-06-06 22:33:59 +02:00
90c2e90e2c
- 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
73 lines
2.2 KiB
Python
73 lines
2.2 KiB
Python
"""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
|