billing: Delete test_subscribe_customer_to_second_plan.

This used to be a more likely codepath, before we introduced
Customer.has_billing_relationship. It is no longer literally impossible to
hit this race condition, so I'm not deleting the code, but it's unlikely
enough that it's not worth figuring out how to test it.
This commit is contained in:
Rishi Gupta
2018-11-27 15:20:58 -08:00
parent 33ec86aa00
commit 698aeddc85
2 changed files with 4 additions and 11 deletions

View File

@@ -205,11 +205,10 @@ def do_replace_coupon(user: UserProfile, coupon: Coupon) -> stripe.Customer:
@catch_stripe_errors @catch_stripe_errors
def do_subscribe_customer_to_plan(user: UserProfile, stripe_customer: stripe.Customer, stripe_plan_id: str, def do_subscribe_customer_to_plan(user: UserProfile, stripe_customer: stripe.Customer, stripe_plan_id: str,
seat_count: int, tax_percent: float, charge_automatically: bool) -> None: seat_count: int, tax_percent: float, charge_automatically: bool) -> None:
if extract_current_subscription(stripe_customer) is not None: if extract_current_subscription(stripe_customer) is not None: # nocoverage
# Most likely due to two people in the org going to the billing page, # Unlikely race condition from two people upgrading (clicking "Make payment")
# and then both upgrading their plan. We don't send clients # at exactly the same time. Doesn't fully resolve the race condition, but having
# real-time event updates for the billing pages, so this is more # a check here reduces the likelihood.
# likely than it would be in other parts of the app.
billing_logger.error("Stripe customer %s trying to subscribe to %s, " billing_logger.error("Stripe customer %s trying to subscribe to %s, "
"but has an active subscription" % (stripe_customer.id, stripe_plan_id)) "but has an active subscription" % (stripe_customer.id, stripe_plan_id))
raise BillingError('subscribing with existing subscription', BillingError.TRY_RELOADING) raise BillingError('subscribing with existing subscription', BillingError.TRY_RELOADING)

View File

@@ -643,12 +643,6 @@ class StripeTest(ZulipTestCase):
do_deactivate_user(user2) do_deactivate_user(user2)
self.assertEqual(get_seat_count(realm), initial_count) self.assertEqual(get_seat_count(realm), initial_count)
def test_subscribe_customer_to_second_plan(self) -> None:
with self.assertRaisesRegex(BillingError, 'subscribing with existing subscription'):
do_subscribe_customer_to_plan(self.example_user("iago"),
mock_customer_with_subscription(),
self.stripe_plan_id, self.quantity, 0, True)
def test_sign_string(self) -> None: def test_sign_string(self) -> None:
string = "abc" string = "abc"
signed_string, salt = sign_string(string) signed_string, salt = sign_string(string)