|
1 | 1 | import os |
| 2 | +import re |
2 | 3 | from pathlib import Path |
3 | 4 |
|
4 | 5 | import httpx |
|
9 | 10 | from mindee.input.path_input import PathInput |
10 | 11 | from mindee.input.url_input_source import URLInputSource |
11 | 12 | from mindee.v2.client import Client |
12 | | -from mindee.v2.error import MindeeAPIV2Error |
13 | | -from mindee.v2.error.mindee_http_error_v2 import MindeeHTTPErrorV2 |
| 13 | +from mindee.v2.error.mindee_http_error_v2 import ( |
| 14 | + MindeeHTTPErrorV2, |
| 15 | + MindeeHTTPUnknownErrorV2, |
| 16 | +) |
14 | 17 | from mindee.v2.parsing import InferenceActiveOptions |
15 | 18 | from mindee.v2.product.extraction.extraction_response import ExtractionResponse |
16 | 19 | from tests.utils import FILE_TYPES_DIR, V2_PRODUCT_DATA_DIR |
@@ -355,16 +358,15 @@ def test_explicit_timeout_failure(findoc_model_id) -> None: |
355 | 358 | @pytest.mark.v2 |
356 | 359 | @pytest.mark.integration |
357 | 360 | @respx.mock |
358 | | -def test_explicit_500_server_error(findoc_model_id) -> None: |
359 | | - respx.post("https://api-v2.mindee.net/v2/inferences/enqueue").mock( |
| 361 | +def test_explicit_500_server_error(findoc_model_id: str) -> None: |
| 362 | + respx.post(re.compile(r"https://api-v2\.mindee\.net/v2/.+/enqueue")).mock( |
360 | 363 | return_value=httpx.Response(500, json={"message": "Internal Server Error"}) |
361 | 364 | ) |
362 | 365 |
|
363 | 366 | client = Client(api_key="dummy") |
364 | 367 | input_source = PathInput(FILE_TYPES_DIR / "pdf" / "blank_1.pdf") |
365 | 368 | params = ExtractionParameters(model_id=findoc_model_id) |
366 | | - |
367 | | - with pytest.raises(MindeeAPIV2Error) as exc_info: |
| 369 | + with pytest.raises(MindeeHTTPUnknownErrorV2) as exc_info: |
368 | 370 | client.enqueue(input_source, params) |
369 | 371 |
|
370 | | - assert exc_info.value.status_code == 500 |
| 372 | + assert "Couldn't deserialize server error" in str(exc_info.value) |
0 commit comments