billing: Don't check for stripe key and plan objects in tests.

Stripe already returns an appropriate error in prod, and these checks are
just a hassle in tests.

Also fixes an error where the check for Plan.objects.exists() was missing
a "not".
This commit is contained in:
Vishnu Ks
2018-07-26 13:46:20 +05:30
committed by Rishi Gupta
parent ecb3879d0c
commit b7d3a1a0f3
2 changed files with 8 additions and 27 deletions

View File

@@ -69,15 +69,14 @@ class StripeError(JsonableError):
def catch_stripe_errors(func: CallableT) -> CallableT:
@wraps(func)
def wrapped(*args: Any, **kwargs: Any) -> Any:
if not settings.TEST_SUITE and STRIPE_PUBLISHABLE_KEY is None:
# Dev-only message; no translation needed.
raise StripeError(
"Missing Stripe config. See https://zulip.readthedocs.io/en/latest/subsystems/billing.html.")
if not Plan.objects.exists():
# Dev-only message; no translation needed.
raise StripeError(
"Plan objects not created. Please run ./manage.py setup_stripe")
if settings.DEVELOPMENT and not settings.TEST_SUITE: # nocoverage
if STRIPE_PUBLISHABLE_KEY is None:
raise AssertionError(
"Missing Stripe config. "
"See https://zulip.readthedocs.io/en/latest/subsystems/billing.html.")
if not Plan.objects.exists():
raise AssertionError(
"Plan objects not created. Please run ./manage.py setup_stripe")
try:
return func(*args, **kwargs)