diff --git a/mindee/mindee_http/mindee_api_v2.py b/mindee/mindee_http/mindee_api_v2.py index 03202f29..940836c4 100644 --- a/mindee/mindee_http/mindee_api_v2.py +++ b/mindee/mindee_http/mindee_api_v2.py @@ -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: @@ -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 diff --git a/mindee/parsing/v2/field/field_location.py b/mindee/parsing/v2/field/field_location.py index 74b20a96..caf5677b 100644 --- a/mindee/parsing/v2/field/field_location.py +++ b/mindee/parsing/v2/field/field_location.py @@ -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. """ diff --git a/tests/test_client_v2_integration.py b/tests/test_client_v2_integration.py index 746b85c1..b88c1d72 100644 --- a/tests/test_client_v2_integration.py +++ b/tests/test_client_v2_integration.py @@ -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") @@ -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(