10
10
11
11
import pytest
12
12
import requests
13
- from requests .auth import AuthBase
14
13
from requests .exceptions import InvalidURL
15
14
16
15
from airbyte_cdk .models import AirbyteLogMessage , AirbyteMessage , Level , SyncMode , Type
29
28
ResponseAction ,
30
29
)
31
30
from airbyte_cdk .sources .streams .http .exceptions import (
32
- DefaultBackoffException ,
33
31
RequestBodyException ,
34
32
UserDefinedBackoffException ,
35
33
)
36
- from airbyte_cdk .sources .streams .http .http_client import (
37
- HttpClient ,
38
- MessageRepresentationAirbyteTracedErrors ,
39
- )
34
+ from airbyte_cdk .sources .streams .http .http_client import HttpClient
40
35
from airbyte_cdk .sources .streams .http .requests_native_auth import TokenAuthenticator
36
+ from airbyte_cdk .utils import AirbyteTracedException
41
37
from airbyte_cdk .utils .airbyte_secrets_utils import update_secrets
42
38
43
39
@@ -190,7 +186,7 @@ def test_stub_custom_backoff_http_stream(mocker):
190
186
191
187
send_mock = mocker .patch .object (requests .Session , "send" , return_value = req )
192
188
193
- with pytest .raises (MessageRepresentationAirbyteTracedErrors ):
189
+ with pytest .raises (AirbyteTracedException ):
194
190
list (stream .read_records (SyncMode .full_refresh ))
195
191
assert send_mock .call_count == stream .max_retries + 1
196
192
@@ -251,7 +247,7 @@ def test_4xx_error_codes_http_stream(mocker, http_code):
251
247
req .status_code = http_code
252
248
mocker .patch .object (requests .Session , "send" , return_value = req )
253
249
254
- with pytest .raises (MessageRepresentationAirbyteTracedErrors ):
250
+ with pytest .raises (AirbyteTracedException ):
255
251
list (stream .read_records (SyncMode .full_refresh ))
256
252
257
253
@@ -283,7 +279,7 @@ def test_error_codes_http_stream_error_resolution_with_response_secrets_filtered
283
279
mocker .patch .object (requests .Session , "send" , return_value = res )
284
280
285
281
# proceed
286
- with pytest .raises (MessageRepresentationAirbyteTracedErrors ) as err :
282
+ with pytest .raises (AirbyteTracedException ) as err :
287
283
list (stream .read_records (SyncMode .full_refresh ))
288
284
289
285
# we expect the header secrets are obscured
@@ -308,7 +304,7 @@ def test_raise_on_http_errors_off_429(mocker):
308
304
309
305
mocker .patch .object (requests .Session , "send" , return_value = req )
310
306
with pytest .raises (
311
- MessageRepresentationAirbyteTracedErrors ,
307
+ AirbyteTracedException ,
312
308
match = "Exhausted available request attempts. Please see logs for more details. Exception: HTTP Status Code: 429. Error: Too many requests." ,
313
309
):
314
310
stream .exit_on_rate_limit = True
@@ -323,7 +319,7 @@ def test_raise_on_http_errors_off_5xx(mocker, status_code):
323
319
req .status_code = status_code
324
320
325
321
send_mock = mocker .patch .object (requests .Session , "send" , return_value = req )
326
- with pytest .raises (MessageRepresentationAirbyteTracedErrors ):
322
+ with pytest .raises (AirbyteTracedException ):
327
323
list (stream .read_records (SyncMode .full_refresh ))
328
324
assert send_mock .call_count == stream .max_retries + 1
329
325
@@ -354,7 +350,7 @@ def test_raise_on_http_errors(mocker, error):
354
350
stream = AutoFailFalseHttpStream ()
355
351
send_mock = mocker .patch .object (requests .Session , "send" , side_effect = error ())
356
352
357
- with pytest .raises (MessageRepresentationAirbyteTracedErrors ):
353
+ with pytest .raises (AirbyteTracedException ):
358
354
list (stream .read_records (SyncMode .full_refresh ))
359
355
assert send_mock .call_count == stream .max_retries + 1
360
356
@@ -613,7 +609,7 @@ def test_send_raise_on_http_errors_logs(mocker, status_code):
613
609
res .headers = {}
614
610
mocker .patch .object (requests .Session , "send" , return_value = res )
615
611
mocker .patch .object (stream ._http_client , "_logger" )
616
- with pytest .raises (MessageRepresentationAirbyteTracedErrors ):
612
+ with pytest .raises (AirbyteTracedException ):
617
613
_ , response = stream ._http_client .send_request (
618
614
"GET" , "https://g" , {}, exit_on_rate_limit = True
619
615
)
0 commit comments