mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-22 21:28:12 +02:00
chore: linting
This commit is contained in:
parent
27218304ae
commit
05190da0a9
30 changed files with 148 additions and 123 deletions
|
|
@ -26,7 +26,6 @@ from sqlalchemy.ext.asyncio import AsyncSession
|
|||
from app.app import app, limiter
|
||||
from app.config import config as app_config
|
||||
from app.db import SearchSpace, User, get_async_session
|
||||
from app.routes.search_spaces_routes import create_default_roles_and_membership
|
||||
from app.podcasts.persistence import Podcast, PodcastStatus
|
||||
from app.podcasts.schemas import (
|
||||
DurationTarget,
|
||||
|
|
@ -39,6 +38,7 @@ from app.podcasts.schemas import (
|
|||
)
|
||||
from app.podcasts.service import PodcastService
|
||||
from app.podcasts.tts import SynthesisRequest, SynthesizedAudio, TextToSpeech
|
||||
from app.routes.search_spaces_routes import create_default_roles_and_membership
|
||||
from app.users import current_active_user
|
||||
|
||||
pytestmark = pytest.mark.integration
|
||||
|
|
@ -128,12 +128,8 @@ class FakeStorageBackend:
|
|||
def fake_storage(monkeypatch) -> FakeStorageBackend:
|
||||
"""Route audio storage to an in-memory backend for the stream routes."""
|
||||
backend = FakeStorageBackend()
|
||||
monkeypatch.setattr(
|
||||
"app.podcasts.storage.get_storage_backend", lambda: backend
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
"app.file_storage.factory.get_storage_backend", lambda: backend
|
||||
)
|
||||
monkeypatch.setattr("app.podcasts.storage.get_storage_backend", lambda: backend)
|
||||
monkeypatch.setattr("app.file_storage.factory.get_storage_backend", lambda: backend)
|
||||
return backend
|
||||
|
||||
|
||||
|
|
@ -159,9 +155,7 @@ def bind_task_session(db_session: AsyncSession, monkeypatch) -> AsyncSession:
|
|||
"app.podcasts.tasks.render",
|
||||
"app.podcasts.tasks.runtime",
|
||||
):
|
||||
monkeypatch.setattr(
|
||||
f"{module}.get_celery_session_maker", lambda: _make_session
|
||||
)
|
||||
monkeypatch.setattr(f"{module}.get_celery_session_maker", lambda: _make_session)
|
||||
return db_session
|
||||
|
||||
|
||||
|
|
@ -213,8 +207,12 @@ def build_spec(
|
|||
language=language,
|
||||
style=PodcastStyle.CONVERSATIONAL,
|
||||
speakers=[
|
||||
SpeakerSpec(slot=0, name="Host", role=SpeakerRole.HOST, voice_id=voice_ids[0]),
|
||||
SpeakerSpec(slot=1, name="Guest", role=SpeakerRole.GUEST, voice_id=voice_ids[1]),
|
||||
SpeakerSpec(
|
||||
slot=0, name="Host", role=SpeakerRole.HOST, voice_id=voice_ids[0]
|
||||
),
|
||||
SpeakerSpec(
|
||||
slot=1, name="Guest", role=SpeakerRole.GUEST, voice_id=voice_ids[1]
|
||||
),
|
||||
],
|
||||
duration=DurationTarget(min_minutes=10, max_minutes=20),
|
||||
)
|
||||
|
|
@ -237,7 +235,7 @@ def make_podcast(db_session: AsyncSession):
|
|||
session, so the endpoint under test reads a realistically-built row.
|
||||
"""
|
||||
|
||||
_LADDER = [
|
||||
ladder = [
|
||||
PodcastStatus.AWAITING_BRIEF,
|
||||
PodcastStatus.DRAFTING,
|
||||
PodcastStatus.RENDERING,
|
||||
|
|
@ -259,7 +257,7 @@ def make_podcast(db_session: AsyncSession):
|
|||
await db_session.flush()
|
||||
return podcast
|
||||
|
||||
targets = _LADDER[: _LADDER.index(status) + 1]
|
||||
targets = ladder[: ladder.index(status) + 1]
|
||||
for target in targets:
|
||||
if target is PodcastStatus.AWAITING_BRIEF:
|
||||
await service.attach_brief(podcast, build_spec())
|
||||
|
|
|
|||
|
|
@ -15,9 +15,7 @@ pytestmark = pytest.mark.integration
|
|||
BASE = "/api/v1/podcasts"
|
||||
|
||||
|
||||
async def test_cancel_from_a_live_state_succeeds(
|
||||
client, db_search_space, make_podcast
|
||||
):
|
||||
async def test_cancel_from_a_live_state_succeeds(client, db_search_space, make_podcast):
|
||||
podcast = await make_podcast(
|
||||
search_space_id=db_search_space.id, status=PodcastStatus.AWAITING_BRIEF
|
||||
)
|
||||
|
|
|
|||
|
|
@ -23,18 +23,12 @@ BASE = "/api/v1/podcasts"
|
|||
def preview_tts(monkeypatch, tmp_path) -> FakeTextToSpeech:
|
||||
"""Route preview synthesis to the fake provider and an isolated cache."""
|
||||
provider = FakeTextToSpeech()
|
||||
monkeypatch.setattr(
|
||||
"app.podcasts.api.routes.get_text_to_speech", lambda: provider
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
"app.podcasts.voices.preview.PREVIEW_CACHE_ROOT", tmp_path
|
||||
)
|
||||
monkeypatch.setattr("app.podcasts.api.routes.get_text_to_speech", lambda: provider)
|
||||
monkeypatch.setattr("app.podcasts.voices.preview.PREVIEW_CACHE_ROOT", tmp_path)
|
||||
return provider
|
||||
|
||||
|
||||
async def test_preview_returns_playable_audio_for_a_catalog_voice(
|
||||
client, preview_tts
|
||||
):
|
||||
async def test_preview_returns_playable_audio_for_a_catalog_voice(client, preview_tts):
|
||||
resp = await client.get(f"{BASE}/voices/openai:alloy/preview")
|
||||
|
||||
assert resp.status_code == 200
|
||||
|
|
@ -42,9 +36,7 @@ async def test_preview_returns_playable_audio_for_a_catalog_voice(
|
|||
assert resp.content == b"segment-audio"
|
||||
|
||||
|
||||
async def test_preview_is_synthesised_once_then_served_from_cache(
|
||||
client, preview_tts
|
||||
):
|
||||
async def test_preview_is_synthesised_once_then_served_from_cache(client, preview_tts):
|
||||
first = await client.get(f"{BASE}/voices/openai:alloy/preview")
|
||||
second = await client.get(f"{BASE}/voices/openai:alloy/preview")
|
||||
|
||||
|
|
@ -69,9 +61,7 @@ async def test_preview_voice_of_inactive_provider_is_404(client, preview_tts):
|
|||
assert preview_tts.requests == []
|
||||
|
||||
|
||||
async def test_preview_without_tts_provider_is_503(
|
||||
client, preview_tts, monkeypatch
|
||||
):
|
||||
async def test_preview_without_tts_provider_is_503(client, preview_tts, monkeypatch):
|
||||
monkeypatch.setattr(app_config, "TTS_SERVICE", None)
|
||||
|
||||
resp = await client.get(f"{BASE}/voices/openai:alloy/preview")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue