generated from john/python-template
This commit is contained in:
@@ -34,7 +34,7 @@ async def test_document_type_maintenance_uses_alphabetical_labels(default_sessio
|
||||
|
||||
summaries = await service.list_document_type_summaries()
|
||||
assert [item.label for item in summaries] == ["Archive", "Letter"]
|
||||
assert [item.document_count for item in summaries] == [0, 0]
|
||||
assert [item.reference_count for item in summaries] == [0, 0]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -56,7 +56,7 @@ async def test_document_type_delete_allows_unreferenced_and_blocks_referenced(de
|
||||
await service.create_document(Document(id=uuid4(), name="Typed document", document_type_id=referenced.id))
|
||||
|
||||
summaries = {item.id: item for item in await service.list_document_type_summaries()}
|
||||
assert summaries[referenced.id].document_count == 1
|
||||
assert summaries[referenced.id].reference_count == 1
|
||||
|
||||
await service.delete_document_type(unused.id)
|
||||
with pytest.raises(DocumentTypeError) as caught:
|
||||
@@ -84,7 +84,7 @@ async def test_person_role_maintenance_orders_by_normalized_label(default_sessio
|
||||
assert [item.id for item in await service.list_person_roles(active_only=False)] == [first.id, second.id]
|
||||
assert [item.id for item in await service.list_person_roles()] == [first.id]
|
||||
summaries = {item.id: item for item in await service.list_person_role_summaries()}
|
||||
assert summaries[second.id].link_count == 0
|
||||
assert summaries[second.id].reference_count == 0
|
||||
assert summaries[second.id].is_built_in is False
|
||||
|
||||
|
||||
|
||||
@@ -73,7 +73,10 @@ async def test_create_job_for_document_sorts_sources_and_creates_links(async_ses
|
||||
assert all(source.filename.endswith(".pdf") for source in sources)
|
||||
assert all("A_page" not in source.filename and "b_page" not in source.filename for source in sources)
|
||||
assert all(Path(source.filename).stem == str(source.id) for source in sources)
|
||||
assert all(Path(source.file_path).parent == (tmp_path / "documents" / str(document.id)) for source in sources)
|
||||
assert all(
|
||||
source.file_path == f"documents/{document.id}/{source.filename}"
|
||||
for source in sources
|
||||
)
|
||||
assert [source.file_hash for source in sources] == [
|
||||
"ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb",
|
||||
"3e23e8160039594a33894f6564e1b1348bbd7a0088d42c4acb73eeaed59c009d",
|
||||
@@ -108,7 +111,7 @@ async def test_create_document_job_stores_source_under_document_id_directory(asy
|
||||
assert source is not None
|
||||
assert Path(source.filename).stem == str(source.id)
|
||||
assert result.stored_path.name == source.filename
|
||||
assert Path(source.file_path).parent == expected_parent
|
||||
assert source.file_path == f"documents/{result.document_id}/{source.filename}"
|
||||
assert source.file_hash == "2c8648d103e3dd7ad87660da0f126a1443b6d21ac1bd3ec000c5e24e2373a90c"
|
||||
assert source.file_size_bytes == len(b"image-bytes")
|
||||
|
||||
|
||||
@@ -81,8 +81,20 @@ class TestWorkflowReliability:
|
||||
top_p=None,
|
||||
settings=None,
|
||||
provider=None,
|
||||
source_reference=None,
|
||||
requested_model=None,
|
||||
):
|
||||
_ = (image_path, prompt_name, prompt_text, temperature, top_p, settings, provider)
|
||||
_ = (
|
||||
image_path,
|
||||
prompt_name,
|
||||
prompt_text,
|
||||
temperature,
|
||||
top_p,
|
||||
settings,
|
||||
provider,
|
||||
source_reference,
|
||||
requested_model,
|
||||
)
|
||||
raise TimeoutError("simulated provider timeout")
|
||||
|
||||
monkeypatch.setattr("transcription.services.workflows.transcribe_document_image", _never_returns)
|
||||
@@ -146,9 +158,9 @@ class TestWorkflowReliability:
|
||||
budget_seconds = 0.20
|
||||
real_build = workflows_module.build_provider_input
|
||||
|
||||
def _slow_build(source_arg):
|
||||
def _slow_build(source_arg, **kwargs):
|
||||
time.sleep(setup_seconds)
|
||||
return real_build(source_arg)
|
||||
return real_build(source_arg, **kwargs)
|
||||
|
||||
async def _never_returns(*args, **kwargs):
|
||||
_ = (args, kwargs)
|
||||
|
||||
Reference in New Issue
Block a user