Skip to content

Commit

Permalink
add pdf cases for in memory integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rjanjua committed May 17, 2024
1 parent 47325d7 commit 4e1acf0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion deepset_cloud_sdk/_service/files_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
)
from deepset_cloud_sdk._s3.upload import S3, S3UploadResult, S3UploadSummary
from deepset_cloud_sdk._utils.constants import SUPPORTED_TYPE_SUFFIXES
from deepset_cloud_sdk.models import DeepsetCloudFile, DeepsetCloudFileBase
from deepset_cloud_sdk.models import DeepsetCloudFileBase

logger = structlog.get_logger(__name__)

Expand Down
Binary file modified tests/data/upload_folder/example.pdf
Binary file not shown.
11 changes: 10 additions & 1 deletion tests/integration/service/test_integration_files_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
from deepset_cloud_sdk._service.files_service import (
META_SUFFIX,
SUPPORTED_TYPE_SUFFIXES,
DeepsetCloudFile,
FilesService,
)
from deepset_cloud_sdk.models import DeepsetCloudFile, DeepsetCloudFileBytes


@pytest.mark.asyncio
Expand Down Expand Up @@ -204,13 +204,17 @@ async def test_async_upload_multiple_file_types(
assert file00_metadata == {"file_name_duplicate_check": "file00.txt", "source": "multiple file types"}

async def test_upload_in_memory(self, integration_config: CommonConfig, workspace_name: str) -> None:
with open(Path("./tests/test_data/multiple_file_types/file08.pdf"), "rb") as f:
pdf_contents = f.read()

async with FilesService.factory(integration_config) as file_service:
files = [
DeepsetCloudFile("file1", "file1.txt", {"which": 1}),
DeepsetCloudFile("file2", "file2.txt", {"which": 2}),
DeepsetCloudFile("file3", "file3.txt", {"which": 3}),
DeepsetCloudFile("file4", "file4.txt", {"which": 4}),
DeepsetCloudFile("file5", "file5.txt", {"which": 5}),
DeepsetCloudFileBytes(file_bytes=pdf_contents, name="file6.pdf", meta={"which": 6}),
]
result = await file_service.upload_in_memory(
workspace_name=workspace_name,
Expand All @@ -228,13 +232,18 @@ async def test_upload_in_memory_less_than_session_threshold(
self, integration_config: CommonConfig, workspace_name: str, monkeypatch: MonkeyPatch
) -> None:
monkeypatch.setattr("deepset_cloud_sdk._service.files_service.DIRECT_UPLOAD_THRESHOLD", -1)

with open(Path("./tests/test_data/multiple_file_types/file08.pdf"), "rb") as f:
pdf_contents = f.read()

async with FilesService.factory(integration_config) as file_service:
files = [
DeepsetCloudFile("file1", "file1.txt", {"which": 1}),
DeepsetCloudFile("file2", "file2.txt", {"which": 2}),
DeepsetCloudFile("file3", "file3.txt", {"which": 3}),
DeepsetCloudFile("file4", "file4.txt", {"which": 4}),
DeepsetCloudFile("file5", "file5.txt", {"which": 5}),
DeepsetCloudFileBytes(file_bytes=pdf_contents, name="file6.pdf", meta={"which": 6}),
]
result = await file_service.upload_in_memory(
workspace_name=workspace_name,
Expand Down
Binary file modified tests/test_data/multiple_file_types/file08.pdf
Binary file not shown.

0 comments on commit 4e1acf0

Please sign in to comment.