generated from john/python-template
V3 Updated V3 core documents. Added data folder backup/restore before/after running destructive tests.
This commit is contained in:
@@ -294,7 +294,7 @@ class TestJobService:
|
||||
assert pending_entry.error_detail == "Cancelled by user"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_resubmit_non_transcribed_sources_resets_only_non_transcribed(
|
||||
async def test_resubmit_failed_sources_resets_only_failed(
|
||||
self,
|
||||
job_service: JobService,
|
||||
document_service: DocumentService,
|
||||
@@ -349,7 +349,7 @@ class TestJobService:
|
||||
)
|
||||
await session.commit()
|
||||
|
||||
count = await job_service.resubmit_non_transcribed_sources(job_id=job.id)
|
||||
count = await job_service.resubmit_failed_sources(job_id=job.id)
|
||||
assert count == 1
|
||||
|
||||
refreshed = await job_service.read_job(job_id=job.id)
|
||||
@@ -364,7 +364,63 @@ class TestJobService:
|
||||
assert transcribed_entry.status == JobSourceStatus.TRANSCRIBED
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_resubmit_non_transcribed_sources_blocks_when_processing(
|
||||
async def test_resubmit_failed_sources_blocks_when_only_pending_or_transcribed(
|
||||
self,
|
||||
job_service: JobService,
|
||||
document_service: DocumentService,
|
||||
):
|
||||
document = Document(id=uuid4(), name="resubmit-no-failed-doc")
|
||||
await document_service.create_document(document=document)
|
||||
|
||||
job = Job(document_id=document.id, status=JobStatus.FAILED)
|
||||
await job_service.create_job(job=job)
|
||||
|
||||
async with job_service._session_scope() as session:
|
||||
source_one = Source(
|
||||
document_id=document.id,
|
||||
page_number=1,
|
||||
upload_name="resubmit-pending.jpg",
|
||||
filename="stored-resubmit-pending.jpg",
|
||||
file_path="/uploads/stored-resubmit-pending.jpg",
|
||||
file_hash="1" * 64,
|
||||
file_size_bytes=1,
|
||||
)
|
||||
source_two = Source(
|
||||
document_id=document.id,
|
||||
page_number=2,
|
||||
upload_name="resubmit-done.jpg",
|
||||
filename="stored-resubmit-done.jpg",
|
||||
file_path="/uploads/stored-resubmit-done.jpg",
|
||||
file_hash="2" * 64,
|
||||
file_size_bytes=1,
|
||||
raw_transcription="done text",
|
||||
)
|
||||
session.add(source_one)
|
||||
session.add(source_two)
|
||||
await session.flush()
|
||||
|
||||
session.add(
|
||||
JobSource(
|
||||
job_id=job.id,
|
||||
source_id=source_one.id,
|
||||
status=JobSourceStatus.PENDING,
|
||||
)
|
||||
)
|
||||
session.add(
|
||||
JobSource(
|
||||
job_id=job.id,
|
||||
source_id=source_two.id,
|
||||
status=JobSourceStatus.TRANSCRIBED,
|
||||
raw_transcription="done text",
|
||||
)
|
||||
)
|
||||
await session.commit()
|
||||
|
||||
with pytest.raises(JobResubmitBlockedError):
|
||||
await job_service.resubmit_failed_sources(job_id=job.id)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_resubmit_failed_sources_blocks_when_processing(
|
||||
self,
|
||||
job_service: JobService,
|
||||
document_service: DocumentService,
|
||||
@@ -376,7 +432,7 @@ class TestJobService:
|
||||
await job_service.create_job(job=job)
|
||||
|
||||
with pytest.raises(JobResubmitBlockedError):
|
||||
await job_service.resubmit_non_transcribed_sources(job_id=job.id)
|
||||
await job_service.resubmit_failed_sources(job_id=job.id)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_cancel_job_blocks_transcribed_terminal_jobs(
|
||||
|
||||
@@ -130,7 +130,7 @@ class TestJobsPageRendering:
|
||||
|
||||
assert response.status_code == 200
|
||||
assert "Resubmit Job" in response.text
|
||||
assert "Non-Transcribed Sources:" in response.text
|
||||
assert "Failed Sources:" in response.text
|
||||
assert "Resubmit now" in response.text
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
Reference in New Issue
Block a user