groundx 2.5.6__tar.gz → 2.5.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {groundx-2.5.6 → groundx-2.5.8}/PKG-INFO +2 -1
- {groundx-2.5.6 → groundx-2.5.8}/pyproject.toml +3 -2
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/core/client_wrapper.py +2 -2
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/extract/classes/document.py +3 -1
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/extract/classes/groundx.py +7 -2
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/extract/classes/test_document.py +12 -4
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/extract/classes/test_groundx.py +16 -7
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/extract/settings/settings.py +1 -0
- {groundx-2.5.6 → groundx-2.5.8}/LICENSE +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/README.md +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/__init__.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/buckets/__init__.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/buckets/client.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/buckets/raw_client.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/client.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/core/__init__.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/core/api_error.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/core/datetime_utils.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/core/file.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/core/force_multipart.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/core/http_client.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/core/http_response.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/core/jsonable_encoder.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/core/pydantic_utilities.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/core/query_encoder.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/core/remove_none_from_dict.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/core/request_options.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/core/serialization.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/csv_splitter.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/customer/__init__.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/customer/client.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/customer/raw_client.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/documents/__init__.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/documents/client.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/documents/raw_client.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/environment.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/errors/__init__.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/errors/bad_request_error.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/errors/unauthorized_error.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/extract/__init__.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/extract/agents/__init__.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/extract/agents/agent.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/extract/classes/__init__.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/extract/classes/agent.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/extract/classes/api.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/extract/classes/field.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/extract/classes/prompt.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/extract/classes/test_field.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/extract/classes/test_prompt.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/extract/post_process/__init__.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/extract/post_process/post_process.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/extract/services/.DS_Store +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/extract/services/__init__.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/extract/services/csv.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/extract/services/logger.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/extract/services/logging_cfg.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/extract/services/ratelimit.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/extract/services/sheets_client.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/extract/services/status.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/extract/services/upload.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/extract/services/upload_minio.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/extract/services/upload_s3.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/extract/services/utility.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/extract/settings/__init__.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/extract/settings/test_settings.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/extract/tasks/__init__.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/extract/tasks/utility.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/extract/utility/__init__.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/extract/utility/classes.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/extract/utility/test_utility.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/groups/__init__.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/groups/client.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/groups/raw_client.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/health/__init__.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/health/client.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/health/raw_client.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/ingest.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/py.typed +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/search/__init__.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/search/client.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/search/raw_client.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/search/types/__init__.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/search/types/search_content_request_id.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/__init__.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/bounding_box_detail.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/bucket_detail.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/bucket_list_response.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/bucket_response.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/bucket_update_detail.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/bucket_update_response.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/customer_detail.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/customer_response.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/document.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/document_detail.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/document_list_response.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/document_local_ingest_request.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/document_lookup_response.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/document_response.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/document_type.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/group_detail.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/group_list_response.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/group_response.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/health_response.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/health_response_health.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/health_service.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/health_service_status.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/ingest_local_document.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/ingest_local_document_metadata.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/ingest_remote_document.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/ingest_response.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/ingest_status.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/ingest_status_light.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/ingest_status_progress.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/ingest_status_progress_cancelled.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/ingest_status_progress_complete.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/ingest_status_progress_errors.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/ingest_status_progress_processing.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/message_response.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/meter_detail.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/process_level.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/processes_status_response.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/processing_status.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/search_response.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/search_response_search.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/search_result_item.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/search_result_item_pages_item.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/sort.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/sort_order.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/subscription_detail.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/subscription_detail_meters.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/types/website_source.py +0 -0
- {groundx-2.5.6 → groundx-2.5.8}/src/groundx/version.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: groundx
|
|
3
|
-
Version: 2.5.
|
|
3
|
+
Version: 2.5.8
|
|
4
4
|
Summary:
|
|
5
5
|
License: MIT
|
|
6
6
|
Requires-Python: >=3.8,<4.0
|
|
@@ -33,6 +33,7 @@ Requires-Dist: google-auth-stubs ; extra == "extract"
|
|
|
33
33
|
Requires-Dist: gspread ; extra == "extract"
|
|
34
34
|
Requires-Dist: httpx (>=0.21.2)
|
|
35
35
|
Requires-Dist: minio ; extra == "extract"
|
|
36
|
+
Requires-Dist: pillow ; extra == "extract"
|
|
36
37
|
Requires-Dist: pydantic (>=1.9.2)
|
|
37
38
|
Requires-Dist: pydantic-core (>=2.18.2,<3.0.0)
|
|
38
39
|
Requires-Dist: pytest ; extra == "extract"
|
|
@@ -3,7 +3,7 @@ name = "groundx"
|
|
|
3
3
|
|
|
4
4
|
[tool.poetry]
|
|
5
5
|
name = "groundx"
|
|
6
|
-
version = "2.5.
|
|
6
|
+
version = "2.5.8"
|
|
7
7
|
description = ""
|
|
8
8
|
readme = "README.md"
|
|
9
9
|
authors = []
|
|
@@ -48,6 +48,7 @@ google-auth-stubs = { version = "*", optional = true}
|
|
|
48
48
|
gspread = { version = "*", optional = true}
|
|
49
49
|
httpx = ">=0.21.2"
|
|
50
50
|
minio = { version = "*", optional = true}
|
|
51
|
+
pillow = { version = "*", optional = true}
|
|
51
52
|
pydantic = ">= 1.9.2"
|
|
52
53
|
pydantic-core = "^2.18.2"
|
|
53
54
|
pytest = { version = "*", optional = true}
|
|
@@ -104,7 +105,7 @@ requires = ["poetry-core"]
|
|
|
104
105
|
build-backend = "poetry.core.masonry.api"
|
|
105
106
|
|
|
106
107
|
[tool.poetry.extras]
|
|
107
|
-
extract=["boto3", "celery", "celery-types", "dateparser", "fastapi", "google-api-python-client", "google-api-python-client-stubs", "google-auth-stubs", "gspread", "minio", "
|
|
108
|
+
extract=["boto3", "celery", "celery-types", "dateparser", "fastapi", "google-api-python-client", "google-api-python-client-stubs", "google-auth-stubs", "gspread", "minio", "pillow", "pytest", "redis", "types-boto3", "types-dateparser"]
|
|
108
109
|
|
|
109
110
|
[[tool.mypy.overrides]]
|
|
110
111
|
module = ["dateparser.*"]
|
|
@@ -14,10 +14,10 @@ class BaseClientWrapper:
|
|
|
14
14
|
|
|
15
15
|
def get_headers(self) -> typing.Dict[str, str]:
|
|
16
16
|
headers: typing.Dict[str, str] = {
|
|
17
|
-
"User-Agent": "groundx/2.5.
|
|
17
|
+
"User-Agent": "groundx/2.5.8",
|
|
18
18
|
"X-Fern-Language": "Python",
|
|
19
19
|
"X-Fern-SDK-Name": "groundx",
|
|
20
|
-
"X-Fern-SDK-Version": "2.5.
|
|
20
|
+
"X-Fern-SDK-Version": "2.5.8",
|
|
21
21
|
}
|
|
22
22
|
headers["X-API-Key"] = self.api_key
|
|
23
23
|
return headers
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import json, os, shutil, requests, time, typing
|
|
2
2
|
from datetime import datetime, timezone
|
|
3
3
|
from io import BytesIO
|
|
4
|
+
from pathlib import Path
|
|
4
5
|
from PIL import Image
|
|
5
6
|
from pydantic import BaseModel, ConfigDict, Field, PrivateAttr
|
|
6
7
|
|
|
@@ -41,6 +42,7 @@ class Document(BaseModel):
|
|
|
41
42
|
def from_request(
|
|
42
43
|
cls: typing.Type[DocT],
|
|
43
44
|
base_url: str,
|
|
45
|
+
cache_dir: Path,
|
|
44
46
|
req: "DocumentRequest",
|
|
45
47
|
**data: typing.Any,
|
|
46
48
|
) -> DocT:
|
|
@@ -54,7 +56,7 @@ class Document(BaseModel):
|
|
|
54
56
|
base_url=base_url,
|
|
55
57
|
documentID=req.document_id,
|
|
56
58
|
taskID=req.task_id,
|
|
57
|
-
).xray(clear_cache=req.clear_cache)
|
|
59
|
+
).xray(cache_dir=cache_dir, clear_cache=req.clear_cache)
|
|
58
60
|
|
|
59
61
|
for page in xray_doc.documentPages:
|
|
60
62
|
st.page_images.append(page.pageUrl)
|
|
@@ -19,12 +19,17 @@ class GroundXDocument(BaseModel):
|
|
|
19
19
|
|
|
20
20
|
def xray(
|
|
21
21
|
self,
|
|
22
|
+
cache_dir: Path,
|
|
22
23
|
clear_cache: bool = False,
|
|
23
24
|
is_test: bool = False,
|
|
24
25
|
base: typing.Optional[str] = None,
|
|
25
26
|
) -> "XRayDocument":
|
|
26
27
|
return XRayDocument.download(
|
|
27
|
-
self,
|
|
28
|
+
self,
|
|
29
|
+
cache_dir=cache_dir,
|
|
30
|
+
base=base,
|
|
31
|
+
clear_cache=clear_cache,
|
|
32
|
+
is_test=is_test,
|
|
28
33
|
)
|
|
29
34
|
|
|
30
35
|
|
|
@@ -81,11 +86,11 @@ class XRayDocument(BaseModel):
|
|
|
81
86
|
def download(
|
|
82
87
|
cls,
|
|
83
88
|
gx_doc: GroundXDocument,
|
|
89
|
+
cache_dir: Path,
|
|
84
90
|
clear_cache: bool = False,
|
|
85
91
|
is_test: bool = False,
|
|
86
92
|
base: typing.Optional[str] = None,
|
|
87
93
|
) -> "XRayDocument":
|
|
88
|
-
cache_dir = Path(__file__).resolve().parent.parent / "cache"
|
|
89
94
|
cache_dir.mkdir(parents=True, exist_ok=True)
|
|
90
95
|
cache_file = cache_dir / f"{gx_doc.document_id}-xray.json"
|
|
91
96
|
|
|
@@ -3,6 +3,7 @@ import pytest, typing, unittest
|
|
|
3
3
|
pytest.importorskip("PIL")
|
|
4
4
|
|
|
5
5
|
from io import BytesIO
|
|
6
|
+
from pathlib import Path
|
|
6
7
|
from PIL import Image
|
|
7
8
|
from unittest.mock import patch
|
|
8
9
|
|
|
@@ -14,6 +15,14 @@ def DR(**data: typing.Any) -> DocumentRequest:
|
|
|
14
15
|
return DocumentRequest.model_validate(data)
|
|
15
16
|
|
|
16
17
|
|
|
18
|
+
def test_doc() -> Document:
|
|
19
|
+
return Document.from_request(
|
|
20
|
+
cache_dir=Path("./cache"),
|
|
21
|
+
base_url="",
|
|
22
|
+
req=test_request(),
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
|
|
17
26
|
def test_request() -> DocumentRequest:
|
|
18
27
|
return DR(documentID="D", fileName="F", modelID=1, processorID=1, taskID="T")
|
|
19
28
|
|
|
@@ -28,12 +37,10 @@ class TestDocument(unittest.TestCase):
|
|
|
28
37
|
self.mock_xray.return_value = TestXRay("http://test.co", [])
|
|
29
38
|
|
|
30
39
|
def test_init_name(self) -> None:
|
|
31
|
-
st1: Document =
|
|
32
|
-
base_url="",
|
|
33
|
-
req=test_request(),
|
|
34
|
-
)
|
|
40
|
+
st1: Document = test_doc()
|
|
35
41
|
self.assertEqual(st1.file_name, "F")
|
|
36
42
|
st2: Document = Document.from_request(
|
|
43
|
+
cache_dir=Path("./cache"),
|
|
37
44
|
base_url="",
|
|
38
45
|
req=DR(
|
|
39
46
|
documentID="D", fileName="F.pdf", modelID=1, processorID=1, taskID="T"
|
|
@@ -41,6 +48,7 @@ class TestDocument(unittest.TestCase):
|
|
|
41
48
|
)
|
|
42
49
|
self.assertEqual(st2.file_name, "F.pdf")
|
|
43
50
|
st3: Document = Document.from_request(
|
|
51
|
+
cache_dir=Path("./cache"),
|
|
44
52
|
base_url="",
|
|
45
53
|
req=DR(documentID="D", fileName="F.", modelID=1, processorID=1, taskID="T"),
|
|
46
54
|
)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import requests, typing, unittest
|
|
2
|
+
from pathlib import Path
|
|
2
3
|
from unittest.mock import patch
|
|
3
4
|
|
|
4
5
|
from pydantic import ValidationError
|
|
@@ -42,6 +43,12 @@ def GD(**data: typing.Any) -> GroundXDocument:
|
|
|
42
43
|
return GroundXDocument.model_validate(data)
|
|
43
44
|
|
|
44
45
|
|
|
46
|
+
def test_xray(gx: GroundXDocument) -> XRayDocument:
|
|
47
|
+
return XRayDocument.download(
|
|
48
|
+
gx, cache_dir=Path("./cache"), base="https://upload.test", is_test=True
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
|
|
45
52
|
class TestGroundX(unittest.TestCase):
|
|
46
53
|
def make_dummy_response(
|
|
47
54
|
self,
|
|
@@ -75,7 +82,7 @@ class TestGroundX(unittest.TestCase):
|
|
|
75
82
|
dummy = self.make_dummy_response(payload=payload, status_ok=True)
|
|
76
83
|
with patch("requests.get", return_value=dummy):
|
|
77
84
|
gx = GD(base_url="", documentID="D", taskID="T")
|
|
78
|
-
xdoc =
|
|
85
|
+
xdoc = test_xray(gx)
|
|
79
86
|
self.assertIsInstance(xdoc, XRayDocument)
|
|
80
87
|
self.assertEqual(xdoc.chunks, [])
|
|
81
88
|
self.assertEqual(xdoc.documentPages, [])
|
|
@@ -85,7 +92,7 @@ class TestGroundX(unittest.TestCase):
|
|
|
85
92
|
with patch("requests.get", side_effect=requests.RequestException("no network")):
|
|
86
93
|
gx = GD(base_url="", documentID="D", taskID="T")
|
|
87
94
|
with self.assertRaises(RuntimeError) as cm:
|
|
88
|
-
|
|
95
|
+
test_xray(gx)
|
|
89
96
|
self.assertIn("Error fetching X-ray JSON", str(cm.exception))
|
|
90
97
|
|
|
91
98
|
def test_download_http_error(self):
|
|
@@ -93,7 +100,7 @@ class TestGroundX(unittest.TestCase):
|
|
|
93
100
|
with patch("requests.get", return_value=dummy):
|
|
94
101
|
gx = GD(base_url="", documentID="D", taskID="T")
|
|
95
102
|
with self.assertRaises(RuntimeError) as cm:
|
|
96
|
-
|
|
103
|
+
test_xray(gx)
|
|
97
104
|
self.assertIn("HTTP error!", str(cm.exception))
|
|
98
105
|
|
|
99
106
|
def test_download_json_error(self):
|
|
@@ -101,7 +108,7 @@ class TestGroundX(unittest.TestCase):
|
|
|
101
108
|
with patch("requests.get", return_value=dummy):
|
|
102
109
|
gx = GD(base_url="", documentID="D", taskID="T")
|
|
103
110
|
with self.assertRaises(RuntimeError) as cm:
|
|
104
|
-
|
|
111
|
+
test_xray(gx)
|
|
105
112
|
self.assertIn("Invalid JSON returned", str(cm.exception))
|
|
106
113
|
|
|
107
114
|
def test_validation_error_on_missing_required_fields(self) -> None:
|
|
@@ -113,7 +120,7 @@ class TestGroundX(unittest.TestCase):
|
|
|
113
120
|
with patch("requests.get", return_value=dummy):
|
|
114
121
|
gx = GD(base_url="", documentID="D", taskID="T")
|
|
115
122
|
with self.assertRaises(ValidationError) as cm:
|
|
116
|
-
|
|
123
|
+
test_xray(gx)
|
|
117
124
|
self.assertIn("Field required", str(cm.exception))
|
|
118
125
|
|
|
119
126
|
def test_xray_method_delegates_to_download(self) -> None:
|
|
@@ -121,7 +128,9 @@ class TestGroundX(unittest.TestCase):
|
|
|
121
128
|
|
|
122
129
|
sentinel = object()
|
|
123
130
|
with patch.object(XRayDocument, "download", return_value=sentinel):
|
|
124
|
-
result = gx.xray(
|
|
131
|
+
result = gx.xray(
|
|
132
|
+
cache_dir=Path("./cache"), base="https://upload.test", is_test=True
|
|
133
|
+
)
|
|
125
134
|
self.assertIs(result, sentinel)
|
|
126
135
|
|
|
127
136
|
def test_chunk_json_alias(self) -> None:
|
|
@@ -186,7 +195,7 @@ class TestGroundX(unittest.TestCase):
|
|
|
186
195
|
dummy = self.make_dummy_response(payload=payload, status_ok=True)
|
|
187
196
|
with patch("requests.get", return_value=dummy):
|
|
188
197
|
gx = GD(base_url="", documentID="D", taskID="T")
|
|
189
|
-
xdoc =
|
|
198
|
+
xdoc = test_xray(gx)
|
|
190
199
|
|
|
191
200
|
self.assertEqual(xdoc.fileType, "pdf")
|
|
192
201
|
self.assertEqual(xdoc.fileName, "file.pdf")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|