abhisheksan's picture
Add Whisper transcription support and config
d09ee28
"""Pytest configuration and fixtures."""
import pytest
from fastapi.testclient import TestClient
from unittest.mock import patch
import tempfile
import os
# Ensure API_KEYS is set for testing
os.environ.setdefault("API_KEYS", "test-key-1,test-key-2")
from app.main import app
from app.core.config import settings
@pytest.fixture
def client():
"""Create a test client for the FastAPI app."""
with TestClient(app) as test_client:
yield test_client
@pytest.fixture
def api_key():
"""Get a valid API key for testing."""
return list(settings.api_keys_set)[0]
@pytest.fixture
def invalid_api_key():
"""Get an invalid API key for testing."""
return "invalid-key-for-testing"
@pytest.fixture
def mock_asyncio_subprocess():
"""Mock asyncio subprocess calls for yt-dlp."""
with patch('asyncio.create_subprocess_exec') as mock_exec:
yield mock_exec
@pytest.fixture
def temp_dir():
"""Create a temporary directory for testing."""
with tempfile.TemporaryDirectory() as tmp_dir:
yield tmp_dir
@pytest.fixture
def sample_youtube_url():
"""Sample YouTube URL for testing."""
return "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
@pytest.fixture
def sample_video_id():
"""Sample video ID for testing."""
return "dQw4w9WgXcQ"