-
Notifications
You must be signed in to change notification settings - Fork 743
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: per-process ingest connections (#1058)
* adds per process connections for Google Drive connector
- Loading branch information
1 parent
dd0f582
commit 668d0f1
Showing
7 changed files
with
111 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
test_unstructured_ingest/unit/doc_processor/test_generalized.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from dataclasses import dataclass | ||
|
||
import pytest | ||
|
||
from unstructured.ingest.doc_processor.generalized import ( | ||
process_document, | ||
) | ||
from unstructured.ingest.interfaces import BaseIngestDoc, IngestDocSessionHandleMixin | ||
|
||
|
||
@dataclass | ||
class IngestDocWithSessionHandle(IngestDocSessionHandleMixin, BaseIngestDoc): | ||
pass | ||
|
||
def test_process_document_with_session_handle(mocker): | ||
"""Test that the process_document function calls the doc_processor_fn with the correct | ||
arguments, assigns the session handle, and returns the correct results.""" | ||
mock_session_handle = mocker.MagicMock() | ||
mocker.patch("unstructured.ingest.doc_processor.generalized.session_handle", mock_session_handle) | ||
mock_doc = mocker.MagicMock(spec=(IngestDocWithSessionHandle)) | ||
|
||
result = process_document(mock_doc) | ||
|
||
mock_doc.get_file.assert_called_once_with() | ||
mock_doc.write_result.assert_called_with() | ||
mock_doc.cleanup_file.assert_called_once_with() | ||
assert result == mock_doc.process_file.return_value | ||
assert mock_doc.session_handle == mock_session_handle | ||
|
||
|
||
def test_process_document_no_session_handle(mocker): | ||
"""Test that the process_document function calls does not assign session handle the IngestDoc | ||
does not have the session handle mixin.""" | ||
mocker.patch("unstructured.ingest.doc_processor.generalized.session_handle", mocker.MagicMock()) | ||
mock_doc = mocker.MagicMock(spec=(BaseIngestDoc)) | ||
|
||
process_document(mock_doc) | ||
|
||
assert not hasattr(mock_doc, "session_handle") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "0.10.2" # pragma: no cover | ||
__version__ = "0.10.3" # pragma: no cover |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters