mirror of https://github.com/zulip/zulip.git
billing: Use mock_stripe in test_downgrade_with_no_subscription.
This commit is contained in:
parent
1ec9097f55
commit
a8b95ff801
Binary file not shown.
Binary file not shown.
|
@ -822,18 +822,17 @@ class StripeTest(ZulipTestCase):
|
|||
event_type=RealmAuditLog.STRIPE_PLAN_CHANGED).values_list('extra_data', flat=True).first()),
|
||||
{'plan': None, 'quantity': 123})
|
||||
|
||||
@patch("stripe.Customer.save")
|
||||
@patch("stripe.Customer.retrieve", side_effect=mock_create_customer)
|
||||
def test_downgrade_with_no_subscription(
|
||||
self, mock_retrieve_customer: Mock, mock_save_customer: Mock) -> None:
|
||||
realm = get_realm('zulip')
|
||||
Customer.objects.create(
|
||||
realm=realm, stripe_customer_id=self.stripe_customer_id, has_billing_relationship=True)
|
||||
self.login(self.example_email('iago'))
|
||||
response = self.client_post("/json/billing/downgrade", {})
|
||||
@mock_stripe("Customer.retrieve", "Customer.create")
|
||||
def test_downgrade_with_no_subscription(self, mock2: Mock, mock1: Mock) -> None:
|
||||
user = self.example_user("iago")
|
||||
do_create_customer(user)
|
||||
self.login(user.email)
|
||||
with patch("stripe.Customer.save") as mock_save_customer:
|
||||
with patch("corporate.lib.stripe.billing_logger.error"):
|
||||
response = self.client_post("/json/billing/downgrade", {})
|
||||
mock_save_customer.assert_not_called()
|
||||
self.assert_json_error_contains(response, 'Please reload')
|
||||
self.assertEqual(ujson.loads(response.content)['error_description'], 'downgrade without subscription')
|
||||
mock_save_customer.assert_not_called()
|
||||
|
||||
@patch("stripe.Subscription.delete")
|
||||
@patch("stripe.Customer.retrieve", side_effect=mock_customer_with_account_balance(1234))
|
||||
|
|
Loading…
Reference in New Issue