Skip to content

Commit 30d51b1

Browse files
committed
switch to ATE for clarity
1 parent 6f2939f commit 30d51b1

File tree

3 files changed

+15
-26
lines changed

3 files changed

+15
-26
lines changed

unit_tests/sources/declarative/async_job/test_job_orchestrator.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
from airbyte_cdk.sources.declarative.async_job.job_tracker import JobTracker
2020
from airbyte_cdk.sources.declarative.async_job.repository import AsyncJobRepository
2121
from airbyte_cdk.sources.message import MessageRepository
22-
from airbyte_cdk.sources.streams.http.http_client import MessageRepresentationAirbyteTracedErrors
2322
from airbyte_cdk.sources.types import StreamSlice
2423
from airbyte_cdk.utils import AirbyteTracedException
2524

@@ -244,7 +243,7 @@ def test_given_traced_config_error_when_start_job_and_raise_this_exception_and_a
244243
Since this is a config error, we assume the other jobs will fail for the same reasons.
245244
"""
246245
job_tracker = JobTracker(1)
247-
self._job_repository.start.side_effect = MessageRepresentationAirbyteTracedErrors(
246+
self._job_repository.start.side_effect = AirbyteTracedException(
248247
"Can't create job", failure_type=FailureType.config_error
249248
)
250249

unit_tests/sources/declarative/requesters/test_http_requester.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,12 @@
2929
InterpolatedRequestOptionsProvider,
3030
)
3131
from airbyte_cdk.sources.message import MessageRepository
32-
from airbyte_cdk.sources.streams.call_rate import (
33-
AbstractAPIBudget,
34-
HttpAPIBudget,
35-
MovingWindowCallRatePolicy,
36-
Rate,
37-
)
38-
from airbyte_cdk.sources.streams.http.error_handlers.response_models import ResponseAction
32+
from airbyte_cdk.sources.streams.call_rate import HttpAPIBudget
3933
from airbyte_cdk.sources.streams.http.exceptions import (
4034
RequestBodyException,
4135
)
42-
from airbyte_cdk.sources.streams.http.http_client import MessageRepresentationAirbyteTracedErrors
4336
from airbyte_cdk.sources.types import Config
37+
from airbyte_cdk.utils.traced_exception import AirbyteTracedException
4438

4539

4640
@pytest.fixture
@@ -880,7 +874,7 @@ def test_request_attempt_count_is_tracked_across_retries(http_requester_factory)
880874
response.status_code = 500
881875
http_requester._http_client._session.send.return_value = response
882876

883-
with pytest.raises(MessageRepresentationAirbyteTracedErrors):
877+
with pytest.raises(AirbyteTracedException):
884878
http_requester._http_client._send_with_retry(request=request_mock, request_kwargs={})
885879

886880
assert (
@@ -906,7 +900,7 @@ def test_request_attempt_count_with_exponential_backoff_strategy(http_requester_
906900
response.status_code = 500
907901
http_requester._http_client._session.send.return_value = response
908902

909-
with pytest.raises(MessageRepresentationAirbyteTracedErrors):
903+
with pytest.raises(AirbyteTracedException):
910904
http_requester._http_client._send_with_retry(request=request_mock, request_kwargs={})
911905

912906
assert (
@@ -937,7 +931,7 @@ def test_backoff_strategy_from_manifest_is_respected(http_requester_factory: Any
937931
response.status_code = 500
938932
http_requester._http_client._session.send.return_value = response
939933

940-
with pytest.raises(MessageRepresentationAirbyteTracedErrors):
934+
with pytest.raises(AirbyteTracedException):
941935
http_requester._http_client._send_with_retry(request=request_mock, request_kwargs={})
942936

943937
assert (

unit_tests/sources/streams/http/test_http.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
import pytest
1212
import requests
13-
from requests.auth import AuthBase
1413
from requests.exceptions import InvalidURL
1514

1615
from airbyte_cdk.models import AirbyteLogMessage, AirbyteMessage, Level, SyncMode, Type
@@ -29,15 +28,12 @@
2928
ResponseAction,
3029
)
3130
from airbyte_cdk.sources.streams.http.exceptions import (
32-
DefaultBackoffException,
3331
RequestBodyException,
3432
UserDefinedBackoffException,
3533
)
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
4035
from airbyte_cdk.sources.streams.http.requests_native_auth import TokenAuthenticator
36+
from airbyte_cdk.utils import AirbyteTracedException
4137
from airbyte_cdk.utils.airbyte_secrets_utils import update_secrets
4238

4339

@@ -190,7 +186,7 @@ def test_stub_custom_backoff_http_stream(mocker):
190186

191187
send_mock = mocker.patch.object(requests.Session, "send", return_value=req)
192188

193-
with pytest.raises(MessageRepresentationAirbyteTracedErrors):
189+
with pytest.raises(AirbyteTracedException):
194190
list(stream.read_records(SyncMode.full_refresh))
195191
assert send_mock.call_count == stream.max_retries + 1
196192

@@ -251,7 +247,7 @@ def test_4xx_error_codes_http_stream(mocker, http_code):
251247
req.status_code = http_code
252248
mocker.patch.object(requests.Session, "send", return_value=req)
253249

254-
with pytest.raises(MessageRepresentationAirbyteTracedErrors):
250+
with pytest.raises(AirbyteTracedException):
255251
list(stream.read_records(SyncMode.full_refresh))
256252

257253

@@ -283,7 +279,7 @@ def test_error_codes_http_stream_error_resolution_with_response_secrets_filtered
283279
mocker.patch.object(requests.Session, "send", return_value=res)
284280

285281
# proceed
286-
with pytest.raises(MessageRepresentationAirbyteTracedErrors) as err:
282+
with pytest.raises(AirbyteTracedException) as err:
287283
list(stream.read_records(SyncMode.full_refresh))
288284

289285
# we expect the header secrets are obscured
@@ -308,7 +304,7 @@ def test_raise_on_http_errors_off_429(mocker):
308304

309305
mocker.patch.object(requests.Session, "send", return_value=req)
310306
with pytest.raises(
311-
MessageRepresentationAirbyteTracedErrors,
307+
AirbyteTracedException,
312308
match="Exhausted available request attempts. Please see logs for more details. Exception: HTTP Status Code: 429. Error: Too many requests.",
313309
):
314310
stream.exit_on_rate_limit = True
@@ -323,7 +319,7 @@ def test_raise_on_http_errors_off_5xx(mocker, status_code):
323319
req.status_code = status_code
324320

325321
send_mock = mocker.patch.object(requests.Session, "send", return_value=req)
326-
with pytest.raises(MessageRepresentationAirbyteTracedErrors):
322+
with pytest.raises(AirbyteTracedException):
327323
list(stream.read_records(SyncMode.full_refresh))
328324
assert send_mock.call_count == stream.max_retries + 1
329325

@@ -354,7 +350,7 @@ def test_raise_on_http_errors(mocker, error):
354350
stream = AutoFailFalseHttpStream()
355351
send_mock = mocker.patch.object(requests.Session, "send", side_effect=error())
356352

357-
with pytest.raises(MessageRepresentationAirbyteTracedErrors):
353+
with pytest.raises(AirbyteTracedException):
358354
list(stream.read_records(SyncMode.full_refresh))
359355
assert send_mock.call_count == stream.max_retries + 1
360356

@@ -613,7 +609,7 @@ def test_send_raise_on_http_errors_logs(mocker, status_code):
613609
res.headers = {}
614610
mocker.patch.object(requests.Session, "send", return_value=res)
615611
mocker.patch.object(stream._http_client, "_logger")
616-
with pytest.raises(MessageRepresentationAirbyteTracedErrors):
612+
with pytest.raises(AirbyteTracedException):
617613
_, response = stream._http_client.send_request(
618614
"GET", "https://g", {}, exit_on_rate_limit=True
619615
)

0 commit comments

Comments
 (0)