generated from john/python-template
claude-sonnet-5 review: Phase 1 implemented by gpt-5.3-codex
Quality Gate / gate (push) Failing after 12s
Quality Gate / gate (push) Failing after 12s
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import asyncio
|
||||
from datetime import UTC
|
||||
from datetime import datetime
|
||||
from datetime import timedelta
|
||||
@@ -153,10 +154,33 @@ class TestJobService:
|
||||
finally:
|
||||
event.remove(bind, "before_cursor_execute", capture)
|
||||
|
||||
selects = [item for item in statements if item.lstrip().upper().startswith("SELECT")]
|
||||
assert len(selects) == 1, selects
|
||||
assert "LIMIT" in selects[0].upper()
|
||||
assert "JOIN" not in selects[0].upper()
|
||||
claim_sql = [
|
||||
item
|
||||
for item in statements
|
||||
if item.lstrip().upper().startswith(("SELECT", "UPDATE"))
|
||||
]
|
||||
assert len(claim_sql) == 1, claim_sql
|
||||
assert "LIMIT" in claim_sql[0].upper()
|
||||
assert "JOIN" not in claim_sql[0].upper()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_claim_next_queued_job_is_atomic_on_sqlite(
|
||||
self,
|
||||
job_service: JobService,
|
||||
document_service: DocumentService,
|
||||
):
|
||||
document = await document_service.create_document(Document(id=uuid4(), name="atomic-claim-doc"))
|
||||
queued_job = await job_service.create_job(Job(document_id=document.id, status=JobStatus.QUEUED))
|
||||
|
||||
async def claim_once():
|
||||
claimed = await job_service.claim_next_queued_job()
|
||||
return claimed.id if claimed is not None else None
|
||||
|
||||
first_claim, second_claim = await asyncio.gather(claim_once(), claim_once())
|
||||
|
||||
assert [first_claim, second_claim].count(queued_job.id) == 1
|
||||
assert [first_claim, second_claim].count(None) == 1
|
||||
assert await job_service.claim_next_queued_job() is None
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_create_job_persists_provider_and_model(
|
||||
|
||||
@@ -14,6 +14,7 @@ from transcription.errors import ErrorCategory
|
||||
from transcription.services.documents import DocumentDeleteBlockedError
|
||||
from transcription.services.documents import DocumentService
|
||||
from transcription.services.errors import SourceDeleteBlockedError
|
||||
from transcription.services.errors import TranscriptionError
|
||||
from transcription.services.evidence import EvidenceService
|
||||
from transcription.services.jobs import JobService
|
||||
from transcription.services.people import PeopleError
|
||||
@@ -190,6 +191,37 @@ async def test_transcription_service_job_source_crud_uses_caller_session(default
|
||||
assert len(await transcriptions.list_job_sources(job_id=job.id)) == 0
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_create_job_source_rejects_duplicate_job_source_membership(default_session_factory):
|
||||
documents = DocumentService(session_factory=default_session_factory)
|
||||
jobs = JobService(session_factory=default_session_factory)
|
||||
transcriptions = SourceService(session_factory=default_session_factory)
|
||||
|
||||
document = await documents.create_document(Document(id=uuid4(), name="duplicate-job-source-doc"))
|
||||
job = await jobs.create_job(Job(document_id=document.id))
|
||||
source = await transcriptions.create_source(
|
||||
Source(
|
||||
document_id=document.id,
|
||||
page_number=1,
|
||||
upload_name="duplicate.jpg",
|
||||
filename="duplicate.jpg",
|
||||
file_path="uploads/duplicate.jpg",
|
||||
file_hash="d" * 64,
|
||||
file_size_bytes=1,
|
||||
)
|
||||
)
|
||||
await transcriptions.create_job_source(
|
||||
JobSource(job_id=job.id, source_id=source.id, status=JobSourceStatus.PENDING)
|
||||
)
|
||||
|
||||
with pytest.raises(TranscriptionError) as duplicate:
|
||||
await transcriptions.create_job_source(
|
||||
JobSource(job_id=job.id, source_id=source.id, status=JobSourceStatus.PENDING)
|
||||
)
|
||||
|
||||
assert duplicate.value.category == ErrorCategory.CONFLICT
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_document_detail_loads_linked_person_relationship(default_session_factory):
|
||||
documents = DocumentService(session_factory=default_session_factory)
|
||||
|
||||
Reference in New Issue
Block a user