Files
alvaro dfed03ac7c chore(vocero): remove the legacy ApiPilot integration (#3)
Vocero now retrieves AquaPortal content through authenticated MCP. This removes the obsolete ApiPilot integration from the API and browser while preserving the separately deployed speech pipeline.

Release notes:

- Removed ApiPilot endpoints, configuration, credential overrides, and HTTP/realtime tool execution.
- Removed browser ApiPilot catalog loading and prompt generation while retaining authenticated MCP discovery.
- Updated regression coverage and operating documentation for the retired routes and settings.

Reviewed-on: AquaPortal/s2s#3
2026-10-08 11:23:41 -04:00

97 lines
3.8 KiB
Python

"""Validate owned fields without tightening or rewriting upstream payloads."""
import pytest
from fastapi.responses import JSONResponse
from pydantic import ValidationError
from vocero_api.api.responses import validated_json_response
from vocero_api.models.requests import QueueEndPayload, SearchRequest
from vocero_api.models.responses import (
AllocationResponse,
QueueCancellationResponse,
ReasoningResponse,
ReportsResponse,
SearchResponse,
UserProfileResponse,
)
@pytest.mark.parametrize(
("model", "payload"),
[
(AllocationResponse, {}),
(AllocationResponse, {"state": [1, None], "connectUrl": "wss://host", "future": {"x": 1.0}}),
(ReasoningResponse, {"answer": "á", "future": [1, None, True]}),
(SearchResponse, {"query": "q", "answer": {"x": 2}, "results": [{"title": [], "snippet": 7, "url": None}]}),
(
ReportsResponse,
{"count": 1, "wrappedLen": 2, "hints": [], "entries": [{"sourceScheduleLabel": 42, "date": None}]},
),
*[(UserProfileResponse, payload) for payload in [{}, [], 42, False, None, "profile"]],
],
)
def test_upstream_values_and_missing_fields_keep_exact_wire_bytes(model, payload):
original = JSONResponse(payload, status_code=202)
validated = validated_json_response(payload, model, status_code=202)
assert validated.body == original.body
assert validated.raw_headers == original.raw_headers
assert validated.status_code == original.status_code
@pytest.mark.parametrize("payload", [{}, {"ok": "true"}, {"ok": 1}, {"ok": None}])
def test_owned_response_fields_are_actually_validated(payload):
with pytest.raises(ValidationError):
validated_json_response(payload, QueueCancellationResponse)
def test_request_models_keep_legacy_extra_field_and_beacon_behavior():
assert SearchRequest.model_validate({"query": "q", "future": True}).model_dump() == {"query": "q", "key": None}
for value in [None, "id", 42, False, [], {}, {"future": True}]:
assert QueueEndPayload.model_validate({"queueId": value, "future": 1}).queueId == value
assert QueueEndPayload.model_validate({}).queueId == ""
def test_http_routes_publish_response_schemas():
# Import the app only after the compatibility suite's isolated configuration.
from vocero_api.main import app
spec = app.openapi()
for path, operations in spec["paths"].items():
if path.startswith("/api/"):
for operation in operations.values():
if "204" in operation["responses"]:
assert path in {"/api/conversations/current", "/api/conversations/current/interrupt"}
assert "content" not in operation["responses"]["204"]
continue
schema = operation["responses"]["200"]["content"]["application/json"]["schema"]
assert "$ref" in schema, path
allocation = spec["components"]["schemas"]["AllocationResponse"]
assert not allocation.get("required")
assert allocation["additionalProperties"] is True
config = spec["components"]["schemas"]["ConfigResponse"]
assert config["properties"]["reasoningType"]["enum"] == ["PROXY", "OPENAI"]
def test_legacy_entry_point_exports_the_renamed_application():
import server
from vocero_api.main import app
assert server.app is app
@pytest.mark.parametrize(
("value", "expected"),
[
("OPENAI", "OPENAI"),
(" 'openai' ", "OPENAI"),
('"OPENAI"', "OPENAI"),
("PROXY", "PROXY"),
("", "PROXY"),
("UNSUPPORTED", "PROXY"),
],
)
def test_reasoning_configuration_preserves_normalization_and_native_fallback(value, expected):
from vocero_api.core.config import _normalize_reasoning_type
assert _normalize_reasoning_type(value) == expected