Skip to content
Merged
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
4 changes: 2 additions & 2 deletions mindee/mindee_http/mindee_api_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def req_post_inference_enqueue(
:param params: Options for the enqueueing of the document.
:return: requests response.
"""
data = {"model_id": params.model_id}
data: Dict[str, Union[str, list]] = {"model_id": params.model_id}
url = f"{self.url_root}/inferences/enqueue"

if params.rag is not None:
Expand All @@ -91,7 +91,7 @@ def req_post_inference_enqueue(
if params.polygon is not None:
data["polygon"] = str(params.polygon).lower()
if params.webhook_ids and len(params.webhook_ids) > 0:
data["webhook_ids"] = ",".join(params.webhook_ids)
data["webhook_ids"] = params.webhook_ids
if params.alias and len(params.alias):
data["alias"] = params.alias

Expand Down
2 changes: 1 addition & 1 deletion mindee/parsing/v2/field/field_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class FieldLocation:

def __init__(self, server_response: StringDict) -> None:
"""
Initialize FieldLocation from server response.
Initialize FieldLocation from the server response.

:param server_response: Raw server response.
"""
Expand Down
53 changes: 51 additions & 2 deletions tests/test_client_v2_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@ def test_parse_file_filled_single_page_must_succeed(

@pytest.mark.integration
@pytest.mark.v2
def test_invalid_uuid_must_throw_error_422(v2_client: ClientV2) -> None:
def test_invalid_uuid_must_throw_error(v2_client: ClientV2) -> None:
"""
Using an invalid model identifier must trigger a 422 HTTP error.
"""
input_path: Path = FILE_TYPES_DIR / "pdf" / "multipage_cut-2.pdf"
input_path: Path = FILE_TYPES_DIR / "pdf" / "blank_1.pdf"

input_source = PathInput(input_path)
params = InferenceParameters(model_id="INVALID MODEL ID")
Expand All @@ -173,6 +173,55 @@ def test_invalid_uuid_must_throw_error_422(v2_client: ClientV2) -> None:
assert exc.status == 422


@pytest.mark.integration
@pytest.mark.v2
def test_unknown_model_must_throw_error(v2_client: ClientV2) -> None:
"""
Using an unknown model identifier must trigger a 404 HTTP error.
"""
input_path: Path = FILE_TYPES_DIR / "pdf" / "blank_1.pdf"

input_source = PathInput(input_path)
params = InferenceParameters(model_id="fc405e37-4ba4-4d03-aeba-533a8d1f0f21")

with pytest.raises(MindeeHTTPErrorV2) as exc_info:
v2_client.enqueue_inference(input_source, params)

exc: MindeeHTTPErrorV2 = exc_info.value
assert exc.status == 404


@pytest.mark.integration
@pytest.mark.v2
def test_unknown_webhook_ids_must_throw_error(
v2_client: ClientV2, findoc_model_id: str
) -> None:
"""
Using an unknown webhook identifier must trigger an error.
"""
input_path: Path = FILE_TYPES_DIR / "pdf" / "blank_1.pdf"

input_source = PathInput(input_path)
params = InferenceParameters(
model_id=findoc_model_id,
webhook_ids=[
"fc405e37-4ba4-4d03-aeba-533a8d1f0f21",
"fc405e37-4ba4-4d03-aeba-533a8d1f0f21",
],
rag=None,
raw_text=None,
polygon=None,
confidence=None,
)

with pytest.raises(MindeeHTTPErrorV2) as exc_info:
v2_client.enqueue_inference(input_source, params)

exc: MindeeHTTPErrorV2 = exc_info.value
assert exc.status == 422
assert "no matching webhooks" in exc.detail.lower()


@pytest.mark.integration
@pytest.mark.v2
def test_url_input_source_must_not_raise_errors(
Expand Down