fix(scada): preserve observation fields in chart evidence
Generic Container CI/CD / test-build-publish (push) Successful in 4m10s
Server CI/CD v2 / build-test-publish-and-deploy (push) Successful in 4m10s

This commit is contained in:
2026-11-12 12:22:07 +08:00
parent 2e8fe86f3f
commit 1892b1d1f0
5 changed files with 75 additions and 3 deletions
+25
View File
@@ -1116,6 +1116,31 @@ def test_time_series_sql_is_bounded_and_field_names_cannot_inject_sql():
asyncio.run(check())
@pytest.mark.parametrize("field", ["monitored_value", "cleaned_value"])
def test_scada_detail_preserves_the_requested_field_with_its_value_alias(monkeypatch, field):
at = datetime.now(timezone.utc)
monkeypatch.setattr(query_service, "permissions_for_context", lambda ctx: PERMISSIONS)
monkeypatch.setattr(query_service.reads, "series_rows", AsyncMock(return_value=[{
"device_id": "D1", "time": at, "value": 32.0,
}]))
monkeypatch.setattr(query_service.reads, "scada_devices", AsyncMock(return_value=[{
"device_id": "D1", "measurement_unit": "m",
}]))
class Scope:
project = object()
connection = Connection()
@asynccontextmanager
async def timescale(self):
yield self.connection
args = ScadaInput(context_handle="a" * 43, device_ids=["D1"], field=field,
start=at - timedelta(hours=3), end=at)
result = asyncio.run(query_service.execute_query(Scope(), binding(), TOOLS["query_scada_readings"], args))
assert result.data[0][field] == result.data[0]["value"] == 32.0
def test_analysis_preserves_run_units_and_reports_inference(monkeypatch):
from app.mcp.models import AnalysisValuesInput
from unittest.mock import AsyncMock