Skip to content

Commit 30b7b99

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent a1aaf14 commit 30b7b99

File tree

2 files changed

+14
-25
lines changed

2 files changed

+14
-25
lines changed

payments/paypal/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ def is_invalid_request(self):
8585
return self.status_code == 400
8686

8787

88-
8988
def authorize(fun):
9089
@wraps(fun)
9190
def wrapper(*args, **kwargs):

payments/paypal/test_paypal.py

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -522,9 +522,7 @@ def test_provider_get_with_none_payment(paypal_provider):
522522
expected_token = "test_access_token"
523523
expected_token_type = "Bearer"
524524

525-
with patch("requests.post") as mocked_post, patch(
526-
"requests.get"
527-
) as mocked_get:
525+
with patch("requests.post") as mocked_post, patch("requests.get") as mocked_get:
528526
# Mock for token acquisition
529527
token_response_mock = MagicMock()
530528
token_response_mock.json.return_value = {
@@ -589,9 +587,7 @@ def test_provider_get_with_none_payment_handles_401(paypal_provider):
589587
expected_token = "test_access_token"
590588
expected_token_type = "Bearer"
591589

592-
with patch("requests.post") as mocked_post, patch(
593-
"requests.get"
594-
) as mocked_get:
590+
with patch("requests.post") as mocked_post, patch("requests.get") as mocked_get:
595591
# Mock for token acquisition (called twice due to 401 retry)
596592
token_response_mock = MagicMock()
597593
token_response_mock.json.return_value = {
@@ -604,15 +600,15 @@ def test_provider_get_with_none_payment_handles_401(paypal_provider):
604600
# Mock for the GET request - first 401, then success
605601
get_response_401 = MagicMock()
606602
get_response_401.status_code = 401
607-
603+
608604
get_response_200 = MagicMock()
609605
get_response_200.json.return_value = expected_get_response_data
610606
get_response_200.status_code = 200
611607

612608
mocked_post.return_value = token_response_mock
613609
mocked_get.side_effect = [
614610
HTTPError(response=get_response_401),
615-
get_response_200
611+
get_response_200,
616612
]
617613

618614
response_data = paypal_provider.get(None, test_url)
@@ -644,10 +640,12 @@ def test_paypal_api_error_structure(paypal_provider):
644640
"name": "RESOURCE_NOT_FOUND",
645641
"message": "The specified resource does not exist.",
646642
"debug_id": "test_debug_id_123",
647-
"details": [{
648-
"issue": "INVALID_RESOURCE_ID",
649-
"description": "Specified resource ID does not exist."
650-
}]
643+
"details": [
644+
{
645+
"issue": "INVALID_RESOURCE_ID",
646+
"description": "Specified resource ID does not exist.",
647+
}
648+
],
651649
}
652650
error_response.status_code = 404
653651

@@ -672,9 +670,7 @@ def test_paypal_api_error_is_not_found():
672670
from payments.paypal import PaypalApiError
673671

674672
error = PaypalApiError(
675-
message="Not found",
676-
status_code=404,
677-
error_name="RESOURCE_NOT_FOUND"
673+
message="Not found", status_code=404, error_name="RESOURCE_NOT_FOUND"
678674
)
679675
assert error.is_not_found() is True
680676
assert error.is_already_cancelled() is False
@@ -686,9 +682,7 @@ def test_paypal_api_error_is_already_cancelled():
686682
from payments.paypal import PaypalApiError
687683

688684
error = PaypalApiError(
689-
message="Unprocessable",
690-
status_code=422,
691-
error_name="UNPROCESSABLE_ENTITY"
685+
message="Unprocessable", status_code=422, error_name="UNPROCESSABLE_ENTITY"
692686
)
693687
assert error.is_not_found() is False
694688
assert error.is_already_cancelled() is True
@@ -700,9 +694,7 @@ def test_paypal_api_error_is_invalid_request():
700694
from payments.paypal import PaypalApiError
701695

702696
error = PaypalApiError(
703-
message="Bad request",
704-
status_code=400,
705-
error_name="INVALID_REQUEST"
697+
message="Bad request", status_code=400, error_name="INVALID_REQUEST"
706698
)
707699
assert error.is_not_found() is False
708700
assert error.is_already_cancelled() is False
@@ -715,9 +707,7 @@ def test_paypal_api_error_backward_compatible():
715707
from payments.paypal import PaypalApiError
716708

717709
error = PaypalApiError(
718-
message="Test error",
719-
status_code=400,
720-
error_name="TEST_ERROR"
710+
message="Test error", status_code=400, error_name="TEST_ERROR"
721711
)
722712

723713
# Should be catchable as PaymentError

0 commit comments

Comments
 (0)