mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-06 22:12:12 +02:00
fix(podcasts): keep legacy episodes readable and guard regenerate
This commit is contained in:
parent
aa7f14d94f
commit
ca9b157676
4 changed files with 66 additions and 9 deletions
|
|
@ -13,7 +13,7 @@ from __future__ import annotations
|
|||
|
||||
import pytest
|
||||
|
||||
from app.podcasts.persistence import PodcastStatus
|
||||
from app.podcasts.persistence import Podcast, PodcastStatus
|
||||
from app.podcasts.service import PodcastService
|
||||
|
||||
from .conftest import build_transcript
|
||||
|
|
@ -179,3 +179,24 @@ async def test_revert_when_nothing_was_regenerated_is_rejected(
|
|||
resp = await client.post(f"{BASE}/{podcast.id}/regenerate/revert")
|
||||
|
||||
assert resp.status_code == 409
|
||||
|
||||
|
||||
async def test_regenerate_without_a_brief_is_rejected(
|
||||
client, db_session, db_search_space, captured_tasks
|
||||
):
|
||||
# Legacy episodes finished before briefs existed; reopening a gate with
|
||||
# nothing to review would strand them there.
|
||||
podcast = Podcast(
|
||||
title="Legacy Episode",
|
||||
search_space_id=db_search_space.id,
|
||||
status=PodcastStatus.READY,
|
||||
spec_version=1,
|
||||
file_location="/var/old/podcast.mp3",
|
||||
)
|
||||
db_session.add(podcast)
|
||||
await db_session.flush()
|
||||
|
||||
resp = await client.post(f"{BASE}/{podcast.id}/transcript/regenerate")
|
||||
|
||||
assert resp.status_code == 422
|
||||
assert captured_tasks.draft == []
|
||||
|
|
|
|||
|
|
@ -53,6 +53,28 @@ def test_an_awaiting_brief_podcast_exposes_the_deserialized_brief(make_spec):
|
|||
assert detail.spec.language == "fr"
|
||||
|
||||
|
||||
def test_a_legacy_episode_still_exposes_its_transcript_and_audio():
|
||||
# Pre-rework rows stored [{speaker_id, dialog}] and a local file path;
|
||||
# they must keep flowing through the new read model, not fail validation.
|
||||
podcast = _podcast(
|
||||
status=PodcastStatus.READY,
|
||||
podcast_transcript=[
|
||||
{"speaker_id": 0, "dialog": "Welcome back."},
|
||||
{"speaker_id": 1, "dialog": "Glad to be here."},
|
||||
],
|
||||
file_location="/var/old/podcast.mp3",
|
||||
)
|
||||
|
||||
detail = PodcastDetail.of(podcast)
|
||||
|
||||
assert detail.has_audio is True
|
||||
assert detail.transcript is not None
|
||||
assert [(turn.speaker, turn.text) for turn in detail.transcript.turns] == [
|
||||
(0, "Welcome back."),
|
||||
(1, "Glad to be here."),
|
||||
]
|
||||
|
||||
|
||||
def test_a_ready_podcast_reports_available_audio(make_spec, make_transcript):
|
||||
podcast = _podcast(
|
||||
status=PodcastStatus.READY,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue