fix(sfm): /health reports the real service version, not a stale 0.1.0
terra-view's SFM Admin page (/admin/sfm) displays whatever /health returns for `version`. That was hardcoded to "0.1.0" and never bumped, so the page showed 0.1.0 while the service was actually 0.26.0. Point both /health and the FastAPI OpenAPI version at the release-bumped TOOL_VERSION (single source of truth), so they can't drift again. Adds httpx-free regression tests (call health() directly). Note: minimateplus.__version__ is separately stale at 0.1.0 — left as-is here (nothing user-facing reads it; touching the package __init__ risks import order). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YDXjZCr4RqT2U3QvMDhgzf
This commit is contained in:
+3
-2
@@ -67,6 +67,7 @@ from minimateplus.blastware_file import write_blastware_file, blastware_filename
|
|||||||
from minimateplus.client import _decode_a5_metadata_into, _decode_a5_waveform, _decode_event_count
|
from minimateplus.client import _decode_a5_metadata_into, _decode_a5_waveform, _decode_event_count
|
||||||
from minimateplus.framing import build_bw_write_frame, SESSION_RESET, POLL_PROBE, POLL_DATA
|
from minimateplus.framing import build_bw_write_frame, SESSION_RESET, POLL_PROBE, POLL_DATA
|
||||||
from minimateplus.protocol import SUB_STOP_MONITORING
|
from minimateplus.protocol import SUB_STOP_MONITORING
|
||||||
|
from minimateplus.event_file_io import TOOL_VERSION as SFM_VERSION # single source for the service version (release-bumped)
|
||||||
from sfm import event_hdf5
|
from sfm import event_hdf5
|
||||||
from sfm.cache import SFMCache, get_cache
|
from sfm.cache import SFMCache, get_cache
|
||||||
from sfm.database import SeismoDb
|
from sfm.database import SeismoDb
|
||||||
@@ -90,7 +91,7 @@ app = FastAPI(
|
|||||||
"Implements the minimateplus RS-232 protocol library.\n"
|
"Implements the minimateplus RS-232 protocol library.\n"
|
||||||
"Proxied by terra-view at /api/sfm/*."
|
"Proxied by terra-view at /api/sfm/*."
|
||||||
),
|
),
|
||||||
version="0.26.0",
|
version=SFM_VERSION,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Allow requests from the waveform viewer opened as a local file (file://)
|
# Allow requests from the waveform viewer opened as a local file (file://)
|
||||||
@@ -371,7 +372,7 @@ def _backfill_events(events: list, info: "DeviceInfo") -> None:
|
|||||||
@app.get("/health")
|
@app.get("/health")
|
||||||
def health() -> dict:
|
def health() -> dict:
|
||||||
"""Service heartbeat. No device I/O."""
|
"""Service heartbeat. No device I/O."""
|
||||||
return {"status": "ok", "service": "sfm", "version": "0.1.0"}
|
return {"status": "ok", "service": "sfm", "version": SFM_VERSION}
|
||||||
|
|
||||||
|
|
||||||
@app.get("/", response_class=FileResponse)
|
@app.get("/", response_class=FileResponse)
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
"""The /health version must track the release, not a stale literal.
|
||||||
|
|
||||||
|
terra-view's SFM Admin page displays whatever `/health` reports. It was
|
||||||
|
hardcoded to "0.1.0" and never bumped, so the page showed 0.1.0 while the
|
||||||
|
service was actually 0.26.0. These guard against that regression — and run
|
||||||
|
without httpx (they call the endpoint function directly, no TestClient).
|
||||||
|
"""
|
||||||
|
from minimateplus.event_file_io import TOOL_VERSION
|
||||||
|
from sfm.server import app, health
|
||||||
|
|
||||||
|
|
||||||
|
def test_health_reports_current_tool_version():
|
||||||
|
assert health()["version"] == TOOL_VERSION
|
||||||
|
|
||||||
|
|
||||||
|
def test_openapi_version_matches_tool_version():
|
||||||
|
assert app.version == TOOL_VERSION
|
||||||
Reference in New Issue
Block a user