Esempio n. 1
0
    def test_stripe_checkout_cancelled(self):
        sub = PromotedSubscription()

        assert not sub.stripe_checkout_cancelled

        sub.update(payment_cancelled_at=datetime.datetime.now())

        assert sub.stripe_checkout_cancelled
Esempio n. 2
0
    def test_stripe_checkout_completed(self):
        sub = PromotedSubscription()

        assert not sub.stripe_checkout_completed

        sub.update(checkout_completed_at=datetime.datetime.now())

        assert sub.stripe_checkout_completed
Esempio n. 3
0
def test_retrieve_stripe_checkout_session():
    stripe_session_id = "some stripe session id"
    sub = PromotedSubscription(stripe_session_id=stripe_session_id)

    with mock.patch("olympia.promoted.utils.stripe.checkout.Session.retrieve"
                    ) as stripe_retrieve:
        retrieve_stripe_checkout_session(subscription=sub)

        stripe_retrieve.assert_called_once_with(stripe_session_id)
def test_retrieve_stripe_subscription():
    stripe_subscription_id = 'some stripe subscription id'
    sub = PromotedSubscription(stripe_subscription_id=stripe_subscription_id)
    fake_subscription = 'fake-stripe-subscription'

    with mock.patch('olympia.promoted.utils.stripe.Subscription.retrieve'
                    ) as stripe_retrieve:
        stripe_retrieve.return_value = fake_subscription

        stripe_sub = retrieve_stripe_subscription(subscription=sub)

        assert stripe_sub == fake_subscription
        stripe_retrieve.assert_called_once_with(stripe_subscription_id)
Esempio n. 5
0
    def test_is_active(self):
        sub = PromotedSubscription()

        assert sub.is_active is None

        sub.update(checkout_completed_at=datetime.datetime.now())

        assert sub.is_active

        sub.update(cancelled_at=datetime.datetime.now())

        assert sub.is_active is False
Esempio n. 6
0
    def test_get_onboarding_url_with_new_object(self):
        sub = PromotedSubscription()

        assert sub.get_onboarding_url() is None