generated from john/python-template
V4.5 Complete - Enhanced trancription context, added option to restranscribe source under different models.
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
"""Integration tests for end-to-end upload and worker pipeline behavior."""
|
||||
|
||||
import io
|
||||
from pathlib import Path
|
||||
from uuid import uuid4
|
||||
|
||||
import pytest
|
||||
from PIL import Image
|
||||
|
||||
from transcription.config import Settings
|
||||
from transcription.db.models import Document
|
||||
@@ -18,6 +20,12 @@ from transcription.services.store import create_job_for_document
|
||||
from transcription.services.workflows import advance_job
|
||||
|
||||
|
||||
def _jpeg_bytes(color: str = "white") -> bytes:
|
||||
output = io.BytesIO()
|
||||
Image.new("RGB", (2, 2), color=color).save(output, format="JPEG")
|
||||
return output.getvalue()
|
||||
|
||||
|
||||
def _build_services(default_session_factory) -> ServiceBundle:
|
||||
services = ServiceBundle()
|
||||
object.__setattr__(
|
||||
@@ -56,7 +64,7 @@ class TestPipelineSuccessFlow:
|
||||
)
|
||||
upload_result = await create_document_job(
|
||||
filename="pipeline.jpg",
|
||||
file_bytes=b"pipeline-bytes",
|
||||
file_bytes=_jpeg_bytes(),
|
||||
session=async_session,
|
||||
settings=settings,
|
||||
)
|
||||
@@ -141,9 +149,9 @@ class TestPipelineSuccessFlow:
|
||||
create_result = await create_job_for_document(
|
||||
document_id=document.id,
|
||||
source_files=[
|
||||
("page-01.jpg", b"one"),
|
||||
("page-02.jpg", b"two"),
|
||||
("page-03.jpg", b"three"),
|
||||
("page-01.jpg", _jpeg_bytes("white")),
|
||||
("page-02.jpg", _jpeg_bytes("gray")),
|
||||
("page-03.jpg", _jpeg_bytes("black")),
|
||||
],
|
||||
session=async_session,
|
||||
settings=settings,
|
||||
@@ -206,8 +214,8 @@ class TestPipelineSuccessFlow:
|
||||
create_result = await create_job_for_document(
|
||||
document_id=document.id,
|
||||
source_files=[
|
||||
("page-01.jpg", b"one"),
|
||||
("page-02.jpg", b"two"),
|
||||
("page-01.jpg", _jpeg_bytes("white")),
|
||||
("page-02.jpg", _jpeg_bytes("gray")),
|
||||
],
|
||||
session=async_session,
|
||||
settings=settings,
|
||||
@@ -272,8 +280,8 @@ class TestPipelineSuccessFlow:
|
||||
create_result = await create_job_for_document(
|
||||
document_id=document.id,
|
||||
source_files=[
|
||||
("page-01.jpg", b"one"),
|
||||
("page-02.jpg", b"two"),
|
||||
("page-01.jpg", _jpeg_bytes("white")),
|
||||
("page-02.jpg", _jpeg_bytes("gray")),
|
||||
],
|
||||
session=async_session,
|
||||
settings=settings,
|
||||
@@ -346,7 +354,7 @@ class TestPipelineFailureFlow:
|
||||
settings = Settings(openrouter_api_key="test-key", upload_dir=tmp_path)
|
||||
upload_result = await create_document_job(
|
||||
filename="pipeline.jpg",
|
||||
file_bytes=b"pipeline-bytes",
|
||||
file_bytes=_jpeg_bytes(),
|
||||
session=async_session,
|
||||
settings=settings,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user