Add a 5 min trial period to subscriptions for test purposes iff

ADD_TRIAL_PERIOD_TO_SUBSCRIPTION is set to true
This commit is contained in:
PCoder 2019-07-18 09:35:57 +05:30
commit 9b3e292598
5 changed files with 17 additions and 8 deletions

View file

@ -1,5 +1,7 @@
import datetime
import uuid
from time import sleep
from unittest import skipIf
from unittest.mock import patch
import stripe
@ -8,7 +10,6 @@ from django.conf import settings
from django.http.request import HttpRequest
from django.test import Client
from django.test import TestCase, override_settings
from unittest import skipIf
from model_mommy import mommy
from datacenterlight.models import StripePlan
@ -231,7 +232,8 @@ class StripePlanTestCase(TestStripeCustomerDescription):
result = self.stripe_utils.subscribe_customer_to_plan(
stripe_customer.stripe_id,
[{"plan": stripe_plan.get(
'response_object').stripe_plan_id}])
'response_object').stripe_plan_id}],
int(datetime.datetime.now().timestamp()) + 300 if settings.ADD_5MIN_TRIAL_TO_SUBSCRIPTION else None)
self.assertIsInstance(result.get('response_object'),
stripe.Subscription)
self.assertIsNone(result.get('error'))
@ -247,7 +249,8 @@ class StripePlanTestCase(TestStripeCustomerDescription):
result = self.stripe_utils.subscribe_customer_to_plan(
stripe_customer.stripe_id,
[{"plan": stripe_plan.get(
'response_object').stripe_plan_id}])
'response_object').stripe_plan_id}],
int(datetime.datetime.now().timestamp()) + 300 if settings.ADD_5MIN_TRIAL_TO_SUBSCRIPTION else None)
self.assertIsNone(result.get('response_object'), None)
self.assertIsNotNone(result.get('error'))