Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit bc7dd08

Browse files
committed
fix and update tests
1 parent 4967464 commit bc7dd08

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

billing/tests/test_views.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1643,6 +1643,7 @@ class MockPaymentMethod:
16431643
"sub_123", default_payment_method=payment_method_retrieve_mock.return_value
16441644
)
16451645

1646+
@patch("logging.Logger.error")
16461647
@patch("services.billing.stripe.PaymentMethod.attach")
16471648
@patch("services.billing.stripe.Customer.modify")
16481649
@patch("services.billing.stripe.Subscription.modify")
@@ -1653,6 +1654,7 @@ def test_check_and_handle_delayed_notification_payment_methods_no_subscription(
16531654
subscription_modify_mock,
16541655
customer_modify_mock,
16551656
payment_method_attach_mock,
1657+
log_error_mock,
16561658
):
16571659
class MockPaymentMethod:
16581660
type = "us_bank_account"
@@ -1675,6 +1677,12 @@ class MockPaymentMethod:
16751677
customer_modify_mock.assert_not_called()
16761678
subscription_modify_mock.assert_not_called()
16771679

1680+
log_error_mock.assert_called_once_with(
1681+
"No owners found with that customer_id, something went wrong",
1682+
extra=dict(customer_id="cus_123"),
1683+
)
1684+
1685+
@patch("logging.Logger.error")
16781686
@patch("services.billing.stripe.PaymentMethod.attach")
16791687
@patch("services.billing.stripe.Customer.modify")
16801688
@patch("services.billing.stripe.Subscription.modify")
@@ -1685,6 +1693,7 @@ def test_check_and_handle_delayed_notification_payment_methods_no_customer(
16851693
subscription_modify_mock,
16861694
customer_modify_mock,
16871695
payment_method_attach_mock,
1696+
log_error_mock,
16881697
):
16891698
class MockPaymentMethod:
16901699
type = "us_bank_account"
@@ -1695,15 +1704,19 @@ class MockPaymentMethod:
16951704

16961705
handler = StripeWebhookHandler()
16971706
handler._check_and_handle_delayed_notification_payment_methods(
1698-
"cus_123", "pm_123"
1707+
"cus_1", "pm_123"
16991708
)
17001709

17011710
payment_method_retrieve_mock.assert_called_once_with("pm_123")
17021711
payment_method_attach_mock.assert_not_called()
17031712
customer_modify_mock.assert_not_called()
17041713
subscription_modify_mock.assert_not_called()
17051714

1706-
@patch("logging.Logger.error")
1715+
log_error_mock.assert_called_once_with(
1716+
"No owners found with that customer_id, something went wrong",
1717+
extra=dict(customer_id="cus_1"),
1718+
)
1719+
17071720
@patch("services.billing.stripe.PaymentMethod.attach")
17081721
@patch("services.billing.stripe.Customer.modify")
17091722
@patch("services.billing.stripe.Subscription.modify")

0 commit comments

Comments
 (0)