|
| 1 | +from docling.datamodel.base_models import ConversionStatus |
1 | 2 | from docling.datamodel.service.chunking import ( |
2 | 3 | BaseChunkerOptions as SharedBaseChunkerOptions, |
3 | 4 | ) |
|
11 | 12 | DoclingTaskResult as SharedDoclingTaskResult, |
12 | 13 | DocumentArtifactItem as SharedDocumentArtifactItem, |
13 | 14 | DocumentResultItem as SharedDocumentResultItem, |
| 15 | + ExportDocumentResponse as SharedExportDocumentResponse, |
| 16 | + ExportResult as SharedExportResult, |
14 | 17 | PresignedArtifactResult as SharedPresignedArtifactResult, |
| 18 | + PresignedUrlConvertDocumentResponse as SharedPresignedUrlConvertDocumentResponse, |
15 | 19 | RemoteTargetResult as SharedRemoteTargetResult, |
16 | 20 | ResultType as SharedResultType, |
17 | 21 | ZipArchiveResult as SharedZipArchiveResult, |
|
31 | 35 | DoclingTaskResult, |
32 | 36 | DocumentArtifactItem, |
33 | 37 | DocumentResultItem, |
| 38 | + ExportDocumentResponse, |
34 | 39 | ExportResult, |
35 | 40 | PresignedArtifactResult, |
| 41 | + PresignedUrlConvertDocumentResponse, |
36 | 42 | RemoteTargetResult, |
37 | 43 | ResultType, |
38 | 44 | ZipArchiveResult, |
@@ -69,11 +75,33 @@ def test_jobkit_result_models_are_shared_types(): |
69 | 75 | assert ArtifactRef is SharedArtifactRef |
70 | 76 | assert DocumentArtifactItem is SharedDocumentArtifactItem |
71 | 77 | assert DocumentResultItem is SharedDocumentResultItem |
| 78 | + assert ExportResult is SharedExportResult |
72 | 79 | assert PresignedArtifactResult is SharedPresignedArtifactResult |
| 80 | + assert ( |
| 81 | + PresignedUrlConvertDocumentResponse is SharedPresignedUrlConvertDocumentResponse |
| 82 | + ) |
73 | 83 |
|
74 | 84 |
|
75 | 85 | def test_shared_service_response_still_constructs_from_jobkit_result(): |
76 | 86 | assert ( |
77 | | - ExportResult.model_fields["content"].annotation |
| 87 | + DocumentResultItem.model_fields["document"].annotation |
78 | 88 | is SharedConvertDocumentResponse.model_fields["document"].annotation |
79 | 89 | ) |
| 90 | + assert ( |
| 91 | + DocumentResultItem.model_fields["document"].annotation |
| 92 | + is SharedExportDocumentResponse |
| 93 | + ) |
| 94 | + assert DocumentResultItem.model_fields["document"].serialization_alias == "content" |
| 95 | + assert ExportResult is DocumentResultItem |
| 96 | + |
| 97 | + |
| 98 | +def test_document_result_item_serializes_document_to_legacy_content_field(): |
| 99 | + item = DocumentResultItem( |
| 100 | + document=ExportDocumentResponse(filename="file.pdf"), |
| 101 | + status=ConversionStatus.SUCCESS, |
| 102 | + ) |
| 103 | + |
| 104 | + payload = item.model_dump(mode="json") |
| 105 | + |
| 106 | + assert "document" not in payload |
| 107 | + assert payload["content"]["filename"] == "file.pdf" |
0 commit comments