44import pytest
55
66from mindee import Client , product
7- from mindee .input .sources import PathInput
8- from mindee .mindee_http .error import (
9- MindeeHTTPClientException ,
10- MindeeHTTPServerException ,
7+ from mindee .error .mindee_http_error import (
8+ MindeeHTTPClientError ,
9+ MindeeHTTPServerError ,
1110 handle_error ,
1211)
12+ from mindee .input .sources import PathInput
1313from tests .test_inputs import FILE_TYPES_DIR
1414from tests .utils import clear_envvars , dummy_envvars
1515
@@ -36,32 +36,32 @@ def dummy_file(monkeypatch) -> PathInput:
3636
3737
3838def test_http_client_error (dummy_client : Client , dummy_file : PathInput ):
39- with pytest .raises (MindeeHTTPClientException ):
39+ with pytest .raises (MindeeHTTPClientError ):
4040 dummy_client .parse (product .InvoiceV4 , dummy_file )
4141
4242
4343def test_http_enqueue_client_error (dummy_client : Client , dummy_file : PathInput ):
44- with pytest .raises (MindeeHTTPClientException ):
44+ with pytest .raises (MindeeHTTPClientError ):
4545 dummy_client .enqueue (product .InvoiceV4 , dummy_file )
4646
4747
4848def test_http_parse_client_error (dummy_client : Client , dummy_file : PathInput ):
49- with pytest .raises (MindeeHTTPClientException ):
49+ with pytest .raises (MindeeHTTPClientError ):
5050 dummy_client .parse_queued (product .InvoiceV4 , "dummy-queue-id" )
5151
5252
5353def test_http_enqueue_and_parse_client_error (
5454 dummy_client : Client , dummy_file : PathInput
5555):
56- with pytest .raises (MindeeHTTPClientException ):
56+ with pytest .raises (MindeeHTTPClientError ):
5757 dummy_client .enqueue_and_parse (product .InvoiceV4 , dummy_file )
5858
5959
6060def test_http_400_error ():
6161 error_ref = open (ERROR_DATA_DIR / "error_400_no_details.json" )
6262 error_obj = json .load (error_ref )
6363 error_400 = handle_error ("dummy-url" , error_obj , 400 )
64- with pytest .raises (MindeeHTTPClientException ):
64+ with pytest .raises (MindeeHTTPClientError ):
6565 raise error_400
6666 assert error_400 .status_code == 400
6767 assert error_400 .api_code == "SomeCode"
@@ -73,7 +73,7 @@ def test_http_401_error():
7373 error_ref = open (ERROR_DATA_DIR / "error_401_invalid_token.json" )
7474 error_obj = json .load (error_ref )
7575 error_401 = handle_error ("dummy-url" , error_obj , 401 )
76- with pytest .raises (MindeeHTTPClientException ):
76+ with pytest .raises (MindeeHTTPClientError ):
7777 raise error_401
7878 assert error_401 .status_code == 401
7979 assert error_401 .api_code == "Unauthorized"
@@ -85,7 +85,7 @@ def test_http_429_error():
8585 error_ref = open (ERROR_DATA_DIR / "error_429_too_many_requests.json" )
8686 error_obj = json .load (error_ref )
8787 error_429 = handle_error ("dummy-url" , error_obj , 429 )
88- with pytest .raises (MindeeHTTPClientException ):
88+ with pytest .raises (MindeeHTTPClientError ):
8989 raise error_429
9090 assert error_429 .status_code == 429
9191 assert error_429 .api_code == "TooManyRequests"
@@ -97,7 +97,7 @@ def test_http_500_error():
9797 error_ref = open (ERROR_DATA_DIR / "error_500_inference_fail.json" )
9898 error_obj = json .load (error_ref )
9999 error_500 = handle_error ("dummy-url" , error_obj , 500 )
100- with pytest .raises (MindeeHTTPServerException ):
100+ with pytest .raises (MindeeHTTPServerError ):
101101 raise error_500
102102 assert error_500 .status_code == 500
103103 assert error_500 .api_code == "failure"
@@ -108,7 +108,7 @@ def test_http_500_error():
108108def test_http_500_html_error ():
109109 error_ref_contents = open (ERROR_DATA_DIR / "error_50x.html" ).read ()
110110 error_500 = handle_error ("dummy-url" , error_ref_contents , 500 )
111- with pytest .raises (MindeeHTTPServerException ):
111+ with pytest .raises (MindeeHTTPServerError ):
112112 raise error_500
113113 assert error_500 .status_code == 500
114114 assert error_500 .api_code == "UnknownError"
0 commit comments