Skip to content

Commit c86a055

Browse files
committed
update http stream tests
1 parent f1df8af commit c86a055

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

unit_tests/sources/streams/http/error_handlers/test_http_status_error_handler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ def test_given_ok_response_http_status_error_handler_returns_success_action(mock
3434
403,
3535
ResponseAction.FAIL,
3636
FailureType.config_error,
37-
"Status Code: 403. Error: Forbidden. You don't have permission to access this resource.",
37+
"HTTP Status Code: 403. Error: Forbidden. You don't have permission to access this resource.",
3838
),
3939
(
4040
404,
4141
ResponseAction.FAIL,
4242
FailureType.system_error,
43-
"Status Code: 404. Error: Not found. The requested resource was not found on the server.",
43+
"HTTP Status Code: 404. Error: Not found. The requested resource was not found on the server.",
4444
),
4545
],
4646
)

unit_tests/sources/streams/http/test_http.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,10 @@ def get_error_handler(self) -> Optional[ErrorHandler]:
210210
req.status_code = HTTPStatus.TOO_MANY_REQUESTS
211211
send_mock = mocker.patch.object(requests.Session, "send", return_value=req)
212212

213-
with pytest.raises(UserDefinedBackoffException, match="Too many requests") as excinfo:
213+
with pytest.raises(
214+
AirbyteTracedException, match="Exception: HTTP Status Code: 429. Error: Too many requests."
215+
):
214216
list(stream.read_records(SyncMode.full_refresh))
215-
assert isinstance(excinfo.value.request, requests.PreparedRequest)
216-
assert isinstance(excinfo.value.response, requests.Response)
217217
if retries <= 0:
218218
assert send_mock.call_count == 1
219219
else:

unit_tests/sources/streams/http/test_http_client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ def backoff_time(self, *args, **kwargs):
555555
session_send.return_value = mocked_response
556556

557557
with patch.object(requests.Session, "send", return_value=mocked_response) as mocked_send:
558-
with pytest.raises(UserDefinedBackoffException):
558+
with pytest.raises(AirbyteTracedException) as e:
559559
http_client.send_request(
560560
http_method="get", url="https://test_base_url.com/v1/endpoint", request_kwargs={}
561561
)
@@ -583,7 +583,7 @@ def backoff_time(self, *args, **kwargs):
583583
session_send.return_value = mocked_response
584584

585585
with patch.object(requests.Session, "send", return_value=mocked_response) as mocked_send:
586-
with pytest.raises(UserDefinedBackoffException):
586+
with pytest.raises(AirbyteTracedException) as e:
587587
http_client.send_request(
588588
http_method="get", url="https://test_base_url.com/v1/endpoint", request_kwargs={}
589589
)
@@ -613,7 +613,7 @@ def backoff_time(self, *args, **kwargs):
613613
session_send.return_value = mocked_response
614614

615615
with patch.object(requests.Session, "send", return_value=mocked_response) as mocked_send:
616-
with pytest.raises(UserDefinedBackoffException):
616+
with pytest.raises(AirbyteTracedException) as e:
617617
http_client.send_request(
618618
http_method="get", url="https://test_base_url.com/v1/endpoint", request_kwargs={}
619619
)
@@ -652,7 +652,7 @@ def backoff_time(self, *args, **kwargs):
652652
session_send.return_value = mocked_response
653653

654654
with patch.object(requests.Session, "send", return_value=mocked_response) as mocked_send:
655-
with pytest.raises(UserDefinedBackoffException):
655+
with pytest.raises(AirbyteTracedException) as e:
656656
http_client.send_request(
657657
http_method="get", url="https://test_base_url.com/v1/endpoint", request_kwargs={}
658658
)
@@ -680,7 +680,7 @@ def backoff_time(self, *args, **kwargs):
680680
session_send.return_value = mocked_response
681681

682682
with patch.object(requests.Session, "send", return_value=mocked_response) as mocked_send:
683-
with pytest.raises(UserDefinedBackoffException):
683+
with pytest.raises(AirbyteTracedException) as e:
684684
http_client.send_request(
685685
http_method="get", url="https://test_base_url.com/v1/endpoint", request_kwargs={}
686686
)
@@ -709,7 +709,7 @@ def test_backoff_strategy_endless(
709709
session_send.return_value = mocked_response
710710

711711
with patch.object(requests.Session, "send", return_value=mocked_response) as mocked_send:
712-
with pytest.raises(expected_error):
712+
with pytest.raises(AirbyteTracedException) as e:
713713
http_client.send_request(
714714
http_method="get",
715715
url="https://test_base_url.com/v1/endpoint",

0 commit comments

Comments
 (0)