Add authenticated upload, review, retry and knowledge-selection HTTP flows with bounded JSON processing and frozen OCR policy. Preserve Gemini/OpenAI provider selection and fenced lifecycle semantics; retain FAQ preambles and uncertain vision candidates, and expose opt-in uncalibrated voice transport diagnostics. Include frontend integration examples, aligned contracts and deterministic regressions. Validation: 1767 provider-free tests passed; all 404 PostgreSQL scenarios have passing evidence across the documented runs.
51 lines
2.7 KiB
Python
51 lines
2.7 KiB
Python
"""Execute the example worklet to prove consumed-sample accounting and capture bytes."""
|
|
from pathlib import Path
|
|
import shutil
|
|
import subprocess
|
|
import pytest
|
|
|
|
ROOT=Path(__file__).resolve().parents[2]
|
|
|
|
def test_worklet_capture_playback_and_interruption(tmp_path):
|
|
node=shutil.which('node')
|
|
if not node: pytest.fail('Node is required to exercise the delivered audio example')
|
|
script=r'''
|
|
const fs=require('fs'),vm=require('vm'),assert=require('assert');
|
|
const processors={};
|
|
global.AudioWorkletProcessor=class {constructor(){this.messages=[];this.port={postMessage:m=>this.messages.push(m)};}};
|
|
global.registerProcessor=(name,processor)=>processors[name]=processor;
|
|
vm.runInThisContext(fs.readFileSync(process.argv[2],'utf8'));
|
|
const capture=new processors['rag-capture']();
|
|
capture.process([[new Float32Array(240).fill(.5)]],[]);
|
|
assert.equal(capture.messages.length,1);assert.equal(capture.messages[0].bytes.byteLength,480);
|
|
assert.equal(new DataView(capture.messages[0].bytes).getInt16(0,true),16384);
|
|
const playback=new processors['rag-playback']();
|
|
const message=data=>playback.port.onmessage({data});
|
|
message({type:'start',ref:'a'});message({type:'pcm',ref:'a',samples:new Float32Array(240).buffer});
|
|
assert.equal(playback.messages.length,0);
|
|
playback.process([],[[new Float32Array(120)]]);
|
|
assert.equal(playback.messages.at(-1).played_ms,5);
|
|
message({type:'flush',id:'flush'});
|
|
assert.equal(playback.messages.at(-2).played_ms,5);assert.equal(playback.queue.length,0);
|
|
assert.equal(playback.messages.at(-1).type,'flushed');
|
|
message({type:'start',ref:'b'});message({type:'pcm',ref:'b',samples:new Float32Array(240).buffer});
|
|
message({type:'end',ref:'b'});playback.process([],[[new Float32Array(240)]]);
|
|
assert.equal(playback.messages.at(-1).played_ms,10);assert.equal(playback.refs.size,0);
|
|
'''
|
|
path=tmp_path/'worklet-test.cjs';path.write_text(script)
|
|
subprocess.run([node,str(path),str(ROOT/'examples/voice-audio-worklet.js')],check=True,capture_output=True,timeout=10)
|
|
|
|
|
|
def test_delivered_voice_client_async_ownership_errors_logout_and_close():
|
|
node=shutil.which('node')
|
|
if not node:pytest.fail('Node is required to exercise VoiceClient')
|
|
result=subprocess.run([node,str(ROOT/'tests/support/voice_client_harness.mjs'),'unit'],capture_output=True,text=True,timeout=20)
|
|
assert result.returncode==0,result.stdout+result.stderr
|
|
|
|
|
|
def test_delivered_playback_bounds_and_creation_replay():
|
|
node=shutil.which('node')
|
|
if not node:pytest.fail('Node is required to exercise the delivered example')
|
|
result=subprocess.run([node,str(ROOT/'tests/support/voice_phase2_repairs.mjs')],capture_output=True,text=True,timeout=20)
|
|
assert result.returncode==0,result.stdout+result.stderr
|