Beispiel #1
0
 def test_anonymous_user(self):
     """ This needs to throw an ImproperlyConfigured error so the developer
         can be guided to properly protect the subscription content.
     """
     anon_user = AnonymousUser()
     with self.assertRaises(ImproperlyConfigured):
         user_has_active_subscription(anon_user)
Beispiel #2
0
 def test_anonymous_user(self):
     """ This needs to throw an ImproperlyConfigured error so the developer
         can be guided to properly protect the subscription content.
     """
     anon_user = AnonymousUser()
     with self.assertRaises(ImproperlyConfigured):
         user_has_active_subscription(anon_user)
Beispiel #3
0
    def test_user_has_active_subscription(self):
        # Make the user have an active subscription
        period_start = datetime.datetime(2013, 4, 1, tzinfo=timezone.utc)
        period_end = datetime.datetime(2013, 4, 30, tzinfo=timezone.utc)

        # Start 'em off'
        start = datetime.datetime(2013, 1, 1, 0, 0, 1)  # more realistic start
        CurrentSubscription.objects.create(customer=self.customer,
                                           plan="test",
                                           current_period_start=period_start,
                                           current_period_end=period_end,
                                           amount=(500 /
                                                   decimal.Decimal("100.0")),
                                           status="active",
                                           start=start,
                                           quantity=1)

        # Assert that the user's subscription is action
        self.assertTrue(user_has_active_subscription(self.user))
Beispiel #4
0
    def test_user_has_active_subscription(self):
        # Make the user have an active subscription
        period_start = datetime.datetime(2013, 4, 1, tzinfo=timezone.utc)
        period_end = datetime.datetime(2013, 4, 30, tzinfo=timezone.utc)

        # Start 'em off'
        start = datetime.datetime(2013, 1, 1, 0, 0, 1)  # more realistic start
        CurrentSubscription.objects.create(
            customer=self.customer,
            plan="test",
            current_period_start=period_start,
            current_period_end=period_end,
            amount=(500 / decimal.Decimal("100.0")),
            status="active",
            start=start,
            quantity=1
        )

        # Assert that the user's subscription is action
        self.assertTrue(user_has_active_subscription(self.user))
Beispiel #5
0
 def test_deprecation(self):
     with self.assertWarns(DeprecationWarning):
         from djstripe.utils import user_has_active_subscription
         user_has_active_subscription(self.user)
 def test_deprecation(self):
     with self.assertWarns(DeprecationWarning):
         from djstripe.utils import user_has_active_subscription
         user_has_active_subscription(self.user)
Beispiel #7
0
 def test_user_has_inactive_subscription(self):
     self.assertFalse(user_has_active_subscription(self.user))
Beispiel #8
0
 def test_user_has_inactive_subscription(self):
     self.assertFalse(user_has_active_subscription(self.user))