Skip to content

Commit 28e1180

Browse files
committed
✅ better tests of data schema
1 parent bd72dc6 commit 28e1180

File tree

4 files changed

+12
-18
lines changed

4 files changed

+12
-18
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* :sparkles: add support for data schema replace on v2
77
* :coffin: remove unused feedback calls from CLI
88

9+
910
## v4.31.0 - 2025-11-04
1011
### Changes
1112
* :label: better field typing for v2

mindee/parsing/v2/inference_active_options.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,5 @@ def __str__(self) -> str:
6060
f"\n:Confidence: {self.confidence}"
6161
f"\n:RAG: {self.rag}"
6262
f"\n:Text Context: {self.text_context}"
63+
f"\n\n{self.data_schema}"
6364
)

tests/v2/test_client_integration.py

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import json
12
import os
23
from pathlib import Path
34

@@ -6,9 +7,8 @@
67
from mindee import ClientV2, InferenceParameters, PathInput, UrlInputSource
78
from mindee.error.mindee_http_error_v2 import MindeeHTTPErrorV2
89
from mindee.parsing.v2 import InferenceActiveOptions
9-
from mindee.input.inference_parameters import DataSchema
1010
from mindee.parsing.v2.inference_response import InferenceResponse
11-
from tests.utils import FILE_TYPES_DIR, V2_PRODUCT_DATA_DIR
11+
from tests.utils import FILE_TYPES_DIR, V2_PRODUCT_DATA_DIR, V2_DATA_DIR
1212

1313

1414
@pytest.fixture(scope="session")
@@ -285,6 +285,9 @@ def test_data_schema_must_succeed(
285285
Load a blank PDF from an HTTPS URL and make sure the inference call completes without raising any errors.
286286
"""
287287
input_path: Path = FILE_TYPES_DIR / "pdf" / "blank_1.pdf"
288+
data_schema_replace_path = (
289+
V2_DATA_DIR / "inference" / "data_schema_replace_param.json"
290+
)
288291

289292
input_source = PathInput(input_path)
290293
params = InferenceParameters(
@@ -294,24 +297,13 @@ def test_data_schema_must_succeed(
294297
polygon=False,
295298
confidence=False,
296299
webhook_ids=[],
297-
data_schema=DataSchema(
298-
replace={
299-
"fields": [
300-
{
301-
"name": "test",
302-
"title": "Test",
303-
"is_array": False,
304-
"type": "string",
305-
"description": "A test field",
306-
}
307-
]
308-
}
309-
),
310-
alias="py_integration_data_schema_override",
300+
data_schema=json.loads(data_schema_replace_path.read_text()),
301+
alias="py_integration_data_schema_replace",
311302
)
312303
response: InferenceResponse = v2_client.enqueue_and_get_inference(
313304
input_source, params
314305
)
315306
_basic_assert_success(response=response, page_count=1, model_id=findoc_model_id)
316307
assert response.inference.active_options.data_schema.replace is True
317-
assert response.inference.result.fields["test"] is not None
308+
assert response.inference.result.fields["test_replace"] is not None
309+
assert response.inference.result.fields["test_replace"].value == "a test value"

0 commit comments

Comments
 (0)