Skip to content

Commit 8912e1a

Browse files
committed
🐛 fix for multiple webhooks
1 parent cd12d10 commit 8912e1a

File tree

3 files changed

+53
-4
lines changed

3 files changed

+53
-4
lines changed

mindee/mindee_http/mindee_api_v2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def req_post_inference_enqueue(
7979
:param params: Options for the enqueueing of the document.
8080
:return: requests response.
8181
"""
82-
data = {"model_id": params.model_id}
82+
data: Dict[str, Union[str, list]] = {"model_id": params.model_id}
8383
url = f"{self.url_root}/inferences/enqueue"
8484

8585
if params.rag is not None:
@@ -91,7 +91,7 @@ def req_post_inference_enqueue(
9191
if params.polygon is not None:
9292
data["polygon"] = str(params.polygon).lower()
9393
if params.webhook_ids and len(params.webhook_ids) > 0:
94-
data["webhook_ids"] = ",".join(params.webhook_ids)
94+
data["webhook_ids"] = params.webhook_ids
9595
if params.alias and len(params.alias):
9696
data["alias"] = params.alias
9797

mindee/parsing/v2/field/field_location.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class FieldLocation:
1010

1111
def __init__(self, server_response: StringDict) -> None:
1212
"""
13-
Initialize FieldLocation from server response.
13+
Initialize FieldLocation from the server response.
1414
1515
:param server_response: Raw server response.
1616
"""

tests/test_client_v2_integration.py

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def test_invalid_uuid_must_throw_error_422(v2_client: ClientV2) -> None:
161161
"""
162162
Using an invalid model identifier must trigger a 422 HTTP error.
163163
"""
164-
input_path: Path = FILE_TYPES_DIR / "pdf" / "multipage_cut-2.pdf"
164+
input_path: Path = FILE_TYPES_DIR / "pdf" / "blank_1.pdf"
165165

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

175175

176+
@pytest.mark.integration
177+
@pytest.mark.v2
178+
def test_unknown_model_must_throw_error_404(v2_client: ClientV2) -> None:
179+
"""
180+
Using an unknown model identifier must trigger a 404 HTTP error.
181+
"""
182+
input_path: Path = FILE_TYPES_DIR / "pdf" / "blank_1.pdf"
183+
184+
input_source = PathInput(input_path)
185+
params = InferenceParameters(model_id="fc405e37-4ba4-4d03-aeba-533a8d1f0f21")
186+
187+
with pytest.raises(MindeeHTTPErrorV2) as exc_info:
188+
v2_client.enqueue_inference(input_source, params)
189+
190+
exc: MindeeHTTPErrorV2 = exc_info.value
191+
assert exc.status == 404
192+
193+
194+
@pytest.mark.integration
195+
@pytest.mark.v2
196+
def test_unknown_webhook_ids_must_throw_error_404(
197+
v2_client: ClientV2, findoc_model_id: str
198+
) -> None:
199+
"""
200+
Using an unknown webhook identifier must trigger a 404 HTTP error.
201+
"""
202+
input_path: Path = FILE_TYPES_DIR / "pdf" / "blank_1.pdf"
203+
204+
input_source = PathInput(input_path)
205+
params = InferenceParameters(
206+
model_id=findoc_model_id,
207+
webhook_ids=[
208+
"fc405e37-4ba4-4d03-aeba-533a8d1f0f21",
209+
"fc405e37-4ba4-4d03-aeba-533a8d1f0f21",
210+
],
211+
rag=None,
212+
raw_text=None,
213+
polygon=None,
214+
confidence=None,
215+
)
216+
217+
with pytest.raises(MindeeHTTPErrorV2) as exc_info:
218+
v2_client.enqueue_inference(input_source, params)
219+
220+
exc: MindeeHTTPErrorV2 = exc_info.value
221+
assert exc.status == 422
222+
assert "no matching webhooks" in exc.detail.lower()
223+
224+
176225
@pytest.mark.integration
177226
@pytest.mark.v2
178227
def test_url_input_source_must_not_raise_errors(

0 commit comments

Comments
 (0)