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,6 +1,7 @@
# from django.test import TestCase
import datetime
from time import sleep
from unittest import skipIf
import stripe
from celery.result import AsyncResult
@ -8,7 +9,6 @@ from django.conf import settings
from django.core.management import call_command
from django.test import TestCase, override_settings
from model_mommy import mommy
from unittest import skipIf
from datacenterlight.models import VMTemplate
from datacenterlight.tasks import create_vm_task
@ -119,7 +119,8 @@ class CeleryTaskTestCase(TestCase):
subscription_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)
stripe_subscription_obj = subscription_result.get('response_object')
# Check if the subscription was approved and is active
if stripe_subscription_obj is None \