Enable replay-safe document deletion and public deployment model identifiers with the forward voice-model schema revision. Add GapGPT dialogue and ElevenLabs speech routing, strict extractive grounding, ten-source retrieval and regression coverage. Validation: 199 targeted provider-free tests passed. The full provider-free run stalled and was interrupted; PostgreSQL acceptance was not run because TEST_DATABASE_URL is unset.
35 lines
1.8 KiB
Python
35 lines
1.8 KiB
Python
import json
|
|
from types import SimpleNamespace
|
|
import pytest
|
|
from app.modules.voice.diagnostics import provider_error_summary
|
|
from app.modules.voice.model_catalog import model_catalog
|
|
|
|
|
|
@pytest.mark.parametrize('enabled,selectable,expected', [
|
|
(True, ('local_s2s', 'gemini'), {'embedding', 'ocr', 'openai', 'gemini', 'dialogue', 'stt', 'tts'}),
|
|
(False, ('local_s2s',), {'embedding', 'ocr', 'openai'}),
|
|
(True, (), {'embedding', 'ocr', 'openai'}),
|
|
])
|
|
def test_catalog_only_exposes_deployed_models(enabled, selectable, expected):
|
|
ingest = SimpleNamespace(embedding_model='fixture-embedding', vision_model='fixture-vision', api_key='PRIVATE')
|
|
voice = SimpleNamespace(provider='openai', voice_selectable_providers=selectable,
|
|
local_s2s_enabled=enabled, local_s2s_llm_model='fixture-llm', local_s2s_stt_model='fixture-stt',
|
|
local_s2s_tts_model='fixture-tts', openai_realtime_model='fixture-realtime', gemini_model='fixture-gemini',
|
|
openai_api_key='PRIVATE', local_s2s_token='PRIVATE')
|
|
rows = model_catalog(ingest, voice)
|
|
assert {row['id'] for row in rows} == expected
|
|
assert all(set(row) == {'id', 'label', 'model'} for row in rows)
|
|
assert 'PRIVATE' not in json.dumps(rows)
|
|
|
|
|
|
@pytest.mark.parametrize('error,signature', [
|
|
({'type': 'invalid_request_error', 'code': 'response_cancel_not_active'}, 'code=response_cancel_not_active'),
|
|
({'type': 'PRIVATE', 'code': 'PRIVATE'}, 'type=other code=other'),
|
|
({'type': ['PRIVATE'], 'code': {'message': 'PRIVATE'}}, 'type=other code=other'),
|
|
({}, 'type=other code=other'),
|
|
])
|
|
def test_provider_error_summary_never_logs_payload(caplog, error, signature):
|
|
provider_error_summary('fixture-session', dict(error, message='PRIVATE', param='PRIVATE'))
|
|
assert 'session=fixture-session' in caplog.text and signature in caplog.text
|
|
assert 'PRIVATE' not in caplog.text
|