Skip to content
Closed

test #215

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,12 @@ __pycache__/
.idea/
openapi.json
openapi_client.json

# Environments
.env
.envrc
.venv*
venv*
env/
ENV/
env.bak/
15 changes: 10 additions & 5 deletions _test_unstructured_client/integration/test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import tempfile
from pathlib import Path
from typing import Literal

import httpx
import json
Expand All @@ -15,6 +16,7 @@
from unstructured_client import UnstructuredClient
from unstructured_client.models import shared, operations
from unstructured_client.models.errors import HTTPValidationError
from unstructured_client.models.shared.partition_parameters import Strategy
from unstructured_client.utils.retries import BackoffStrategy, RetryConfig
from unstructured_client._hooks.custom import form_utils
from unstructured_client._hooks.custom import split_pdf_hook
Expand Down Expand Up @@ -106,8 +108,8 @@ def test_integration_split_pdf_has_same_output_as_non_split(
assert len(diff) == 0

@pytest.mark.parametrize( ("filename", "expected_ok", "strategy"), [
("_sample_docs/layout-parser-paper.pdf", True, "hi_res"), # 16
]# pages
("_sample_docs/layout-parser-paper.pdf", True, shared.Strategy.HI_RES), # 16 pages
]
)
@pytest.mark.parametrize( ("use_caching", "cache_dir"), [
(True, None), # Use default cache dir
Expand All @@ -116,8 +118,11 @@ def test_integration_split_pdf_has_same_output_as_non_split(
(False, Path(tempfile.gettempdir()) / "test_integration_unstructured_client2"), # Don't use caching, use custom cache dir
])
def test_integration_split_pdf_with_caching(
filename: str, expected_ok: bool, strategy: str, use_caching: bool,
cache_dir: Path | None
filename: str,
expected_ok: bool,
strategy: Literal[Strategy.HI_RES],
use_caching: bool,
cache_dir: Path | None,
):
try:
response = requests.get("http://localhost:8000/general/docs")
Expand All @@ -143,7 +148,7 @@ def test_integration_split_pdf_with_caching(
languages=["eng"],
split_pdf_page=True,
split_pdf_cache_tmp_data=use_caching,
split_pdf_cache_dir=cache_dir,
split_pdf_cache_tmp_data_dir=str(cache_dir),
)

req = operations.PartitionRequest(
Expand Down
Loading