fix: ruff formatting, allow-direct-references, and noqa for Kubeflow pipeline vars
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
"""
|
||||
Pytest configuration and fixtures for voice-assistant tests.
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import base64
|
||||
import os
|
||||
from typing import AsyncGenerator
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -29,21 +29,54 @@ def event_loop():
|
||||
def sample_audio_b64():
|
||||
"""Sample base64 encoded audio for testing."""
|
||||
# 16-bit PCM silence (44 bytes header + 1000 samples)
|
||||
wav_header = bytes([
|
||||
0x52, 0x49, 0x46, 0x46, # "RIFF"
|
||||
0x24, 0x08, 0x00, 0x00, # File size
|
||||
0x57, 0x41, 0x56, 0x45, # "WAVE"
|
||||
0x66, 0x6D, 0x74, 0x20, # "fmt "
|
||||
0x10, 0x00, 0x00, 0x00, # Chunk size
|
||||
0x01, 0x00, # PCM format
|
||||
0x01, 0x00, # Mono
|
||||
0x80, 0x3E, 0x00, 0x00, # Sample rate (16000)
|
||||
0x00, 0x7D, 0x00, 0x00, # Byte rate
|
||||
0x02, 0x00, # Block align
|
||||
0x10, 0x00, # Bits per sample
|
||||
0x64, 0x61, 0x74, 0x61, # "data"
|
||||
0x00, 0x08, 0x00, 0x00, # Data size
|
||||
])
|
||||
wav_header = bytes(
|
||||
[
|
||||
0x52,
|
||||
0x49,
|
||||
0x46,
|
||||
0x46, # "RIFF"
|
||||
0x24,
|
||||
0x08,
|
||||
0x00,
|
||||
0x00, # File size
|
||||
0x57,
|
||||
0x41,
|
||||
0x56,
|
||||
0x45, # "WAVE"
|
||||
0x66,
|
||||
0x6D,
|
||||
0x74,
|
||||
0x20, # "fmt "
|
||||
0x10,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00, # Chunk size
|
||||
0x01,
|
||||
0x00, # PCM format
|
||||
0x01,
|
||||
0x00, # Mono
|
||||
0x80,
|
||||
0x3E,
|
||||
0x00,
|
||||
0x00, # Sample rate (16000)
|
||||
0x00,
|
||||
0x7D,
|
||||
0x00,
|
||||
0x00, # Byte rate
|
||||
0x02,
|
||||
0x00, # Block align
|
||||
0x10,
|
||||
0x00, # Bits per sample
|
||||
0x64,
|
||||
0x61,
|
||||
0x74,
|
||||
0x61, # "data"
|
||||
0x00,
|
||||
0x08,
|
||||
0x00,
|
||||
0x00, # Data size
|
||||
]
|
||||
)
|
||||
silence = bytes([0x00] * 2048)
|
||||
return base64.b64encode(wav_header + silence).decode()
|
||||
|
||||
@@ -96,13 +129,14 @@ def mock_voice_request(sample_audio_b64):
|
||||
@pytest.fixture
|
||||
def mock_clients():
|
||||
"""Mock all service clients."""
|
||||
with patch("voice_assistant.STTClient") as stt, \
|
||||
patch("voice_assistant.EmbeddingsClient") as embeddings, \
|
||||
patch("voice_assistant.RerankerClient") as reranker, \
|
||||
patch("voice_assistant.LLMClient") as llm, \
|
||||
patch("voice_assistant.TTSClient") as tts, \
|
||||
patch("voice_assistant.MilvusClient") as milvus:
|
||||
|
||||
with (
|
||||
patch("voice_assistant.STTClient") as stt,
|
||||
patch("voice_assistant.EmbeddingsClient") as embeddings,
|
||||
patch("voice_assistant.RerankerClient") as reranker,
|
||||
patch("voice_assistant.LLMClient") as llm,
|
||||
patch("voice_assistant.TTSClient") as tts,
|
||||
patch("voice_assistant.MilvusClient") as milvus,
|
||||
):
|
||||
yield {
|
||||
"stt": stt,
|
||||
"embeddings": embeddings,
|
||||
|
||||
Reference in New Issue
Block a user