Stripe checkout #104411
@ -23,7 +23,6 @@ class TestHasActiveSubscription(TestCase):
|
|||||||
|
|
||||||
def test_true_when_subscription_active(self):
|
def test_true_when_subscription_active(self):
|
||||||
subscription = SubscriptionFactory(
|
subscription = SubscriptionFactory(
|
||||||
customer=UserFactory().customer,
|
|
||||||
plan_id=1,
|
plan_id=1,
|
||||||
status=list(looper.models.Subscription._ACTIVE_STATUSES)[0],
|
status=list(looper.models.Subscription._ACTIVE_STATUSES)[0],
|
||||||
)
|
)
|
||||||
@ -31,19 +30,18 @@ class TestHasActiveSubscription(TestCase):
|
|||||||
self.assertTrue(has_active_subscription(subscription.customer.user))
|
self.assertTrue(has_active_subscription(subscription.customer.user))
|
||||||
|
|
||||||
def test_false_when_subscription_inactive(self):
|
def test_false_when_subscription_inactive(self):
|
||||||
subscription = SubscriptionFactory(customer=UserFactory().customer, plan_id=1)
|
subscription = SubscriptionFactory(plan_id=1)
|
||||||
|
|
||||||
self.assertFalse(has_active_subscription(subscription.customer.user))
|
self.assertFalse(has_active_subscription(subscription.customer.user))
|
||||||
|
|
||||||
def test_false_when_team_subscription_inactive(self):
|
def test_false_when_team_subscription_inactive(self):
|
||||||
team = TeamFactory(subscription__customer=UserFactory().customer, subscription__plan_id=1)
|
team = TeamFactory(subscription__plan_id=1)
|
||||||
team.team_users.create(user=UserFactory())
|
team.team_users.create(user=UserFactory())
|
||||||
|
|
||||||
self.assertFalse(has_active_subscription(team.team_users.first().user))
|
self.assertFalse(has_active_subscription(team.team_users.first().user))
|
||||||
|
|
||||||
def test_true_when_team_subscription_active(self):
|
def test_true_when_team_subscription_active(self):
|
||||||
team = TeamFactory(
|
team = TeamFactory(
|
||||||
subscription__customer=UserFactory().customer,
|
|
||||||
subscription__plan_id=1,
|
subscription__plan_id=1,
|
||||||
subscription__status=list(looper.models.Subscription._ACTIVE_STATUSES)[0],
|
subscription__status=list(looper.models.Subscription._ACTIVE_STATUSES)[0],
|
||||||
)
|
)
|
||||||
@ -60,7 +58,6 @@ class TestHasNotYetCancelledSubscription(TestCase):
|
|||||||
|
|
||||||
def test_true_when_subscription_active(self):
|
def test_true_when_subscription_active(self):
|
||||||
subscription = SubscriptionFactory(
|
subscription = SubscriptionFactory(
|
||||||
customer=UserFactory().customer,
|
|
||||||
plan_id=1,
|
plan_id=1,
|
||||||
status=list(looper.models.Subscription._ACTIVE_STATUSES)[0],
|
status=list(looper.models.Subscription._ACTIVE_STATUSES)[0],
|
||||||
)
|
)
|
||||||
@ -68,26 +65,23 @@ class TestHasNotYetCancelledSubscription(TestCase):
|
|||||||
self.assertTrue(has_not_yet_cancelled_subscription(subscription.customer.user))
|
self.assertTrue(has_not_yet_cancelled_subscription(subscription.customer.user))
|
||||||
|
|
||||||
def test_false_when_subscription_cancelled(self):
|
def test_false_when_subscription_cancelled(self):
|
||||||
subscription = SubscriptionFactory(
|
subscription = SubscriptionFactory(plan_id=1, status='cancelled')
|
||||||
customer=UserFactory().customer, plan_id=1, status='cancelled'
|
|
||||||
)
|
|
||||||
|
|
||||||
self.assertFalse(has_not_yet_cancelled_subscription(subscription.customer.user))
|
self.assertFalse(has_not_yet_cancelled_subscription(subscription.customer.user))
|
||||||
|
|
||||||
def test_true_when_subscription_inactive(self):
|
def test_true_when_subscription_inactive(self):
|
||||||
subscription = SubscriptionFactory(customer=UserFactory().customer, plan_id=1)
|
subscription = SubscriptionFactory(plan_id=1)
|
||||||
|
|
||||||
self.assertTrue(has_not_yet_cancelled_subscription(subscription.customer.user))
|
self.assertTrue(has_not_yet_cancelled_subscription(subscription.customer.user))
|
||||||
|
|
||||||
def test_false_when_team_subscription_inactive(self):
|
def test_false_when_team_subscription_inactive(self):
|
||||||
team = TeamFactory(subscription__customer=UserFactory().customer, subscription__plan_id=1)
|
team = TeamFactory(subscription__plan_id=1)
|
||||||
team.team_users.create(user=UserFactory())
|
team.team_users.create(user=UserFactory())
|
||||||
|
|
||||||
self.assertFalse(has_not_yet_cancelled_subscription(team.team_users.first().user))
|
self.assertFalse(has_not_yet_cancelled_subscription(team.team_users.first().user))
|
||||||
|
|
||||||
def test_false_when_team_subscription_active(self):
|
def test_false_when_team_subscription_active(self):
|
||||||
team = TeamFactory(
|
team = TeamFactory(
|
||||||
subscription__customer=UserFactory().customer,
|
|
||||||
subscription__plan_id=1,
|
subscription__plan_id=1,
|
||||||
subscription__status=list(looper.models.Subscription._ACTIVE_STATUSES)[0],
|
subscription__status=list(looper.models.Subscription._ACTIVE_STATUSES)[0],
|
||||||
)
|
)
|
||||||
@ -97,7 +91,6 @@ class TestHasNotYetCancelledSubscription(TestCase):
|
|||||||
|
|
||||||
def test_false_when_team_subscription_cancelled(self):
|
def test_false_when_team_subscription_cancelled(self):
|
||||||
team = TeamFactory(
|
team = TeamFactory(
|
||||||
subscription__customer=UserFactory().customer,
|
|
||||||
subscription__plan_id=1,
|
subscription__plan_id=1,
|
||||||
subscription__status='cancelled',
|
subscription__status='cancelled',
|
||||||
)
|
)
|
||||||
@ -107,7 +100,6 @@ class TestHasNotYetCancelledSubscription(TestCase):
|
|||||||
|
|
||||||
def test_true_when_team_subscription_cancelled_personal_active(self):
|
def test_true_when_team_subscription_cancelled_personal_active(self):
|
||||||
team = TeamFactory(
|
team = TeamFactory(
|
||||||
subscription__customer=UserFactory().customer,
|
|
||||||
subscription__plan_id=1,
|
subscription__plan_id=1,
|
||||||
subscription__status='cancelled',
|
subscription__status='cancelled',
|
||||||
)
|
)
|
||||||
@ -122,7 +114,6 @@ class TestHasNotYetCancelledSubscription(TestCase):
|
|||||||
|
|
||||||
def test_false_when_team_subscription_active_personal_cancelled(self):
|
def test_false_when_team_subscription_active_personal_cancelled(self):
|
||||||
team = TeamFactory(
|
team = TeamFactory(
|
||||||
subscription__customer=UserFactory().customer,
|
|
||||||
subscription__plan_id=1,
|
subscription__plan_id=1,
|
||||||
subscription__status=list(looper.models.Subscription._ACTIVE_STATUSES)[0],
|
subscription__status=list(looper.models.Subscription._ACTIVE_STATUSES)[0],
|
||||||
)
|
)
|
||||||
@ -144,7 +135,6 @@ class TestHasSubscription(TestCase):
|
|||||||
|
|
||||||
def test_true_when_subscription_active(self):
|
def test_true_when_subscription_active(self):
|
||||||
subscription = SubscriptionFactory(
|
subscription = SubscriptionFactory(
|
||||||
customer=UserFactory().customer,
|
|
||||||
plan_id=1,
|
plan_id=1,
|
||||||
status=list(looper.models.Subscription._ACTIVE_STATUSES)[0],
|
status=list(looper.models.Subscription._ACTIVE_STATUSES)[0],
|
||||||
)
|
)
|
||||||
@ -152,19 +142,18 @@ class TestHasSubscription(TestCase):
|
|||||||
self.assertTrue(has_subscription(subscription.customer.user))
|
self.assertTrue(has_subscription(subscription.customer.user))
|
||||||
|
|
||||||
def test_true_when_subscription_inactive(self):
|
def test_true_when_subscription_inactive(self):
|
||||||
subscription = SubscriptionFactory(customer=UserFactory().customer, plan_id=1)
|
subscription = SubscriptionFactory(plan_id=1)
|
||||||
|
|
||||||
self.assertTrue(has_subscription(subscription.customer.user))
|
self.assertTrue(has_subscription(subscription.customer.user))
|
||||||
|
|
||||||
def test_true_when_team_subscription_inactive(self):
|
def test_true_when_team_subscription_inactive(self):
|
||||||
team = TeamFactory(subscription__customer=UserFactory().customer, subscription__plan_id=1)
|
team = TeamFactory(subscription__plan_id=1)
|
||||||
team.team_users.create(user=UserFactory())
|
team.team_users.create(user=UserFactory())
|
||||||
|
|
||||||
self.assertTrue(has_subscription(team.team_users.first().user))
|
self.assertTrue(has_subscription(team.team_users.first().user))
|
||||||
|
|
||||||
def test_true_when_team_subscription_active(self):
|
def test_true_when_team_subscription_active(self):
|
||||||
team = TeamFactory(
|
team = TeamFactory(
|
||||||
subscription__customer=UserFactory().customer,
|
|
||||||
subscription__plan_id=1,
|
subscription__plan_id=1,
|
||||||
subscription__status=list(looper.models.Subscription._ACTIVE_STATUSES)[0],
|
subscription__status=list(looper.models.Subscription._ACTIVE_STATUSES)[0],
|
||||||
)
|
)
|
||||||
@ -174,7 +163,6 @@ class TestHasSubscription(TestCase):
|
|||||||
|
|
||||||
def test_true_when_subscription_active_is_legacy(self):
|
def test_true_when_subscription_active_is_legacy(self):
|
||||||
subscription = SubscriptionFactory(
|
subscription = SubscriptionFactory(
|
||||||
customer=UserFactory().customer,
|
|
||||||
plan_id=1,
|
plan_id=1,
|
||||||
status=list(looper.models.Subscription._ACTIVE_STATUSES)[0],
|
status=list(looper.models.Subscription._ACTIVE_STATUSES)[0],
|
||||||
is_legacy=True,
|
is_legacy=True,
|
||||||
@ -183,18 +171,12 @@ class TestHasSubscription(TestCase):
|
|||||||
self.assertTrue(has_subscription(subscription.customer.user))
|
self.assertTrue(has_subscription(subscription.customer.user))
|
||||||
|
|
||||||
def test_true_when_subscription_inactive_and_is_legacy(self):
|
def test_true_when_subscription_inactive_and_is_legacy(self):
|
||||||
subscription = SubscriptionFactory(
|
subscription = SubscriptionFactory(plan_id=1, is_legacy=True)
|
||||||
customer=UserFactory().customer, plan_id=1, is_legacy=True
|
|
||||||
)
|
|
||||||
|
|
||||||
self.assertTrue(has_subscription(subscription.customer.user))
|
self.assertTrue(has_subscription(subscription.customer.user))
|
||||||
|
|
||||||
def test_true_when_team_subscription_inactive_and_is_legacy(self):
|
def test_true_when_team_subscription_inactive_and_is_legacy(self):
|
||||||
team = TeamFactory(
|
team = TeamFactory(subscription__plan_id=1, subscription__is_legacy=True)
|
||||||
subscription__customer=UserFactory().customer,
|
|
||||||
subscription__plan_id=1,
|
|
||||||
subscription__is_legacy=True,
|
|
||||||
)
|
|
||||||
team.team_users.create(user=UserFactory())
|
team.team_users.create(user=UserFactory())
|
||||||
|
|
||||||
self.assertTrue(has_subscription(team.team_users.first().user))
|
self.assertTrue(has_subscription(team.team_users.first().user))
|
||||||
@ -208,7 +190,6 @@ class TestHasNonLegacySubscription(TestCase):
|
|||||||
|
|
||||||
def test_true_when_subscription_active_and_not_is_legacy(self):
|
def test_true_when_subscription_active_and_not_is_legacy(self):
|
||||||
subscription = SubscriptionFactory(
|
subscription = SubscriptionFactory(
|
||||||
customer=UserFactory().customer,
|
|
||||||
plan_id=1,
|
plan_id=1,
|
||||||
status=list(looper.models.Subscription._ACTIVE_STATUSES)[0],
|
status=list(looper.models.Subscription._ACTIVE_STATUSES)[0],
|
||||||
)
|
)
|
||||||
@ -216,26 +197,23 @@ class TestHasNonLegacySubscription(TestCase):
|
|||||||
self.assertTrue(has_non_legacy_subscription(subscription.customer.user))
|
self.assertTrue(has_non_legacy_subscription(subscription.customer.user))
|
||||||
|
|
||||||
def test_true_when_subscription_inactive_and_not_is_legacy(self):
|
def test_true_when_subscription_inactive_and_not_is_legacy(self):
|
||||||
subscription = SubscriptionFactory(customer=UserFactory().customer, plan_id=1)
|
subscription = SubscriptionFactory(plan_id=1)
|
||||||
|
|
||||||
self.assertTrue(has_non_legacy_subscription(subscription.customer.user))
|
self.assertTrue(has_non_legacy_subscription(subscription.customer.user))
|
||||||
|
|
||||||
def test_true_when_team_subscription_inactive_and_not_is_legacy(self):
|
def test_true_when_team_subscription_inactive_and_not_is_legacy(self):
|
||||||
team = TeamFactory(subscription__customer=UserFactory().customer, subscription__plan_id=1)
|
team = TeamFactory(subscription__plan_id=1)
|
||||||
team.team_users.create(user=UserFactory())
|
team.team_users.create(user=UserFactory())
|
||||||
|
|
||||||
self.assertTrue(has_non_legacy_subscription(team.team_users.first().user))
|
self.assertTrue(has_non_legacy_subscription(team.team_users.first().user))
|
||||||
|
|
||||||
def test_false_when_subscription_inactive_and_is_legacy(self):
|
def test_false_when_subscription_inactive_and_is_legacy(self):
|
||||||
subscription = SubscriptionFactory(
|
subscription = SubscriptionFactory(plan_id=1, is_legacy=True)
|
||||||
customer=UserFactory().customer, plan_id=1, is_legacy=True
|
|
||||||
)
|
|
||||||
|
|
||||||
self.assertFalse(has_non_legacy_subscription(subscription.customer.user))
|
self.assertFalse(has_non_legacy_subscription(subscription.customer.user))
|
||||||
|
|
||||||
def test_false_when_subscription_active_and_is_legacy(self):
|
def test_false_when_subscription_active_and_is_legacy(self):
|
||||||
subscription = SubscriptionFactory(
|
subscription = SubscriptionFactory(
|
||||||
customer=UserFactory().customer,
|
|
||||||
plan_id=1,
|
plan_id=1,
|
||||||
status=list(looper.models.Subscription._ACTIVE_STATUSES)[0],
|
status=list(looper.models.Subscription._ACTIVE_STATUSES)[0],
|
||||||
is_legacy=True,
|
is_legacy=True,
|
||||||
@ -244,18 +222,13 @@ class TestHasNonLegacySubscription(TestCase):
|
|||||||
self.assertFalse(has_non_legacy_subscription(subscription.customer.user))
|
self.assertFalse(has_non_legacy_subscription(subscription.customer.user))
|
||||||
|
|
||||||
def test_false_when_team_subscription_inactive_and_is_legacy(self):
|
def test_false_when_team_subscription_inactive_and_is_legacy(self):
|
||||||
team = TeamFactory(
|
team = TeamFactory(subscription__plan_id=1, subscription__is_legacy=True)
|
||||||
subscription__customer=UserFactory().customer,
|
|
||||||
subscription__plan_id=1,
|
|
||||||
subscription__is_legacy=True,
|
|
||||||
)
|
|
||||||
team.team_users.create(user=UserFactory())
|
team.team_users.create(user=UserFactory())
|
||||||
|
|
||||||
self.assertFalse(has_non_legacy_subscription(team.team_users.first().user))
|
self.assertFalse(has_non_legacy_subscription(team.team_users.first().user))
|
||||||
|
|
||||||
def test_false_when_team_subscription_active_and_is_legacy(self):
|
def test_false_when_team_subscription_active_and_is_legacy(self):
|
||||||
team = TeamFactory(
|
team = TeamFactory(
|
||||||
subscription__customer=UserFactory().customer,
|
|
||||||
subscription__plan_id=1,
|
subscription__plan_id=1,
|
||||||
subscription__status=list(looper.models.Subscription._ACTIVE_STATUSES)[0],
|
subscription__status=list(looper.models.Subscription._ACTIVE_STATUSES)[0],
|
||||||
subscription__is_legacy=True,
|
subscription__is_legacy=True,
|
||||||
|
@ -19,14 +19,12 @@ class TestAddToTeams(TestCase):
|
|||||||
emails=['test1@example.com', 'test2@example.com'],
|
emails=['test1@example.com', 'test2@example.com'],
|
||||||
name='Team Awesome',
|
name='Team Awesome',
|
||||||
subscription__status='active',
|
subscription__status='active',
|
||||||
subscription__customer=UserFactory().customer,
|
|
||||||
)
|
)
|
||||||
cls.team_unlimited = TeamFactory(
|
cls.team_unlimited = TeamFactory(
|
||||||
seats=None,
|
seats=None,
|
||||||
name='Team Unlimited',
|
name='Team Unlimited',
|
||||||
email_domain='my-awesome-blender-studio.org',
|
email_domain='my-awesome-blender-studio.org',
|
||||||
subscription__status='active',
|
subscription__status='active',
|
||||||
subscription__customer=UserFactory().customer,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@responses.activate
|
@responses.activate
|
||||||
@ -152,7 +150,6 @@ class TestAddToTeams(TestCase):
|
|||||||
name='Team Unlimited',
|
name='Team Unlimited',
|
||||||
email_domain='some-domain.com',
|
email_domain='some-domain.com',
|
||||||
subscription__status='active',
|
subscription__status='active',
|
||||||
subscription__customer=UserFactory().customer,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertTrue(has_active_subscription(user))
|
self.assertTrue(has_active_subscription(user))
|
||||||
@ -185,7 +182,6 @@ class TestAddToTeams(TestCase):
|
|||||||
name='Team Unlimited',
|
name='Team Unlimited',
|
||||||
email_domain='some-domain.com',
|
email_domain='some-domain.com',
|
||||||
subscription__status='active',
|
subscription__status='active',
|
||||||
subscription__customer=UserFactory().customer,
|
|
||||||
)
|
)
|
||||||
self.assertEqual(team.email_domain, 'some-domain.com')
|
self.assertEqual(team.email_domain, 'some-domain.com')
|
||||||
|
|
||||||
@ -236,7 +232,6 @@ class TestAddToTeams(TestCase):
|
|||||||
name='Team Unlimited',
|
name='Team Unlimited',
|
||||||
email_domain='edu.some-domain.com',
|
email_domain='edu.some-domain.com',
|
||||||
subscription__status='active',
|
subscription__status='active',
|
||||||
subscription__customer=UserFactory().customer,
|
|
||||||
)
|
)
|
||||||
self.assertEqual(team.email_domain, 'edu.some-domain.com')
|
self.assertEqual(team.email_domain, 'edu.some-domain.com')
|
||||||
|
|
||||||
@ -270,7 +265,6 @@ class TestAddToTeams(TestCase):
|
|||||||
name='Team Unlimited',
|
name='Team Unlimited',
|
||||||
email_domain='edu.some-domain.com',
|
email_domain='edu.some-domain.com',
|
||||||
subscription__status='active',
|
subscription__status='active',
|
||||||
subscription__customer=UserFactory().customer,
|
|
||||||
)
|
)
|
||||||
self.assertEqual(team.email_domain, 'edu.some-domain.com')
|
self.assertEqual(team.email_domain, 'edu.some-domain.com')
|
||||||
|
|
||||||
|
@ -319,7 +319,6 @@ class TestReceiptPDFView(TestCase):
|
|||||||
seats=4,
|
seats=4,
|
||||||
emails=['test1@example.com', 'test2@example.com'],
|
emails=['test1@example.com', 'test2@example.com'],
|
||||||
name='Team Awesome',
|
name='Team Awesome',
|
||||||
subscription__customer=UserFactory().customer,
|
|
||||||
subscription__plan_id=1,
|
subscription__plan_id=1,
|
||||||
)
|
)
|
||||||
order = OrderFactory(
|
order = OrderFactory(
|
||||||
@ -362,7 +361,6 @@ class TestReceiptPDFView(TestCase):
|
|||||||
seats=4,
|
seats=4,
|
||||||
emails=['test1@example.com', 'test2@example.com'],
|
emails=['test1@example.com', 'test2@example.com'],
|
||||||
name='Team Awesome',
|
name='Team Awesome',
|
||||||
subscription__customer=UserFactory().customer,
|
|
||||||
subscription__plan_id=1,
|
subscription__plan_id=1,
|
||||||
invoice_reference='PO #9876',
|
invoice_reference='PO #9876',
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user