def test_refresh_card_expiry_dates_refreshed():
    """Customer card already marked for 'refresh', so don't send an email."""
    with mock.patch('stripe.Customer.retrieve') as mock_retrieve:
        mock_retrieve.return_value = {
            'default_card': '1234',
            'cards': {
                'data': [
                    {
                        'id': '1234',
                        'exp_month': '8',
                        'exp_year': '1986',
                    },
                ],
            },
        }
        obj = ObjectPaymentPlanFactory(content_object=ContactFactory())
        ObjectPaymentPlanInstalmentFactory(
            object_payment_plan=obj
        )
        ObjectPaymentPlanInstalmentFactory(
            object_payment_plan=obj,
            due=date.today() + relativedelta(months=+1),
        )
        customer = CustomerFactory(
            email=obj.content_object.checkout_email,
            refresh=True,
        )
        ObjectPaymentPlan.objects.refresh_card_expiry_dates()
        customer.refresh_from_db()
        assert True == customer.refresh
        # check we didn't send a notification email
        assert 0 == Message.objects.count()
예제 #2
0
def test_refresh_card_expiry_dates_future():
    with mock.patch("stripe.Customer.retrieve") as mock_retrieve:
        mock_retrieve.return_value = {
            "default_card": "1234",
            "cards": {"data": [{"id": "1234", "exp_month": "8", "exp_year": "2050"}]},
        }
        obj = ObjectPaymentPlanFactory(content_object=ContactFactory())
        ObjectPaymentPlanInstalmentFactory(object_payment_plan=obj)
        ObjectPaymentPlanInstalmentFactory(object_payment_plan=obj, due=date.today() + relativedelta(months=+1))
        customer = CustomerFactory(email=obj.content_object.checkout_email)
        ObjectPaymentPlan.objects.refresh_card_expiry_dates()
        customer.refresh_from_db()
        assert False == customer.refresh
        # check we didn't send a notification email
        assert 0 == Message.objects.count()
예제 #3
0
def test_refresh_card_expiry_dates():
    MailTemplateFactory(slug=Customer.MAIL_TEMPLATE_CARD_EXPIRY)
    with mock.patch("stripe.Customer.retrieve") as mock_retrieve:
        mock_retrieve.return_value = {
            "default_card": "1234",
            "cards": {"data": [{"id": "1234", "exp_month": "8", "exp_year": "1986"}]},
        }
        obj = ObjectPaymentPlanFactory(content_object=ContactFactory())
        ObjectPaymentPlanInstalmentFactory(object_payment_plan=obj)
        ObjectPaymentPlanInstalmentFactory(object_payment_plan=obj, due=date.today() + relativedelta(months=+1))
        customer = CustomerFactory(email=obj.content_object.checkout_email)
        ObjectPaymentPlan.objects.refresh_card_expiry_dates()
        customer.refresh_from_db()
        assert True == customer.refresh
        # check email template context
        assert 1 == Message.objects.count()
        message = Message.objects.first()
        assert 1 == message.mail_set.count()
        mail = message.mail_set.first()
        assert 1 == mail.mailfield_set.count()
        assert {"name": customer.name} == {f.key: f.value for f in mail.mailfield_set.all()}
def test_refresh_card_expiry_dates():
    MailTemplateFactory(slug=Customer.MAIL_TEMPLATE_CARD_EXPIRY)
    with mock.patch('stripe.Customer.retrieve') as mock_retrieve:
        mock_retrieve.return_value = {
            'default_card': '1234',
            'cards': {
                'data': [
                    {
                        'id': '1234',
                        'exp_month': '8',
                        'exp_year': '1986',
                    },
                ],
            },
        }
        obj = ObjectPaymentPlanFactory(content_object=ContactFactory())
        ObjectPaymentPlanInstalmentFactory(
            object_payment_plan=obj
        )
        ObjectPaymentPlanInstalmentFactory(
            object_payment_plan=obj,
            due=date.today() + relativedelta(months=+1),
        )
        customer = CustomerFactory(
            email=obj.content_object.checkout_email
        )
        ObjectPaymentPlan.objects.refresh_card_expiry_dates()
        customer.refresh_from_db()
        assert True == customer.refresh
        # check email template context
        assert 1 == Message.objects.count()
        message = Message.objects.first()
        assert 1 == message.mail_set.count()
        mail = message.mail_set.first()
        assert 1 == mail.mailfield_set.count()
        assert {
            'name': customer.name,
        } == {f.key: f.value for f in mail.mailfield_set.all()}
def test_report_card_expiry_dates():
    object_payment_plan = ObjectPaymentPlanFactory(
        content_object=ContactFactory()
    )
    ObjectPaymentPlanInstalmentFactory(object_payment_plan=object_payment_plan)
    obj = ObjectPaymentPlanInstalmentFactory(
        object_payment_plan=ObjectPaymentPlanFactory(
            content_object=ContactFactory()
        ),
    )
    CustomerFactory(
        email=obj.object_payment_plan.content_object.checkout_email
    )
    ObjectPaymentPlan.objects.report_card_expiry_dates
def test_customer_refresh():
    customer = CustomerFactory(refresh=True)
    assert True == customer.refresh
def test_is_expiring_past():
    customer = CustomerFactory(expiry_date=date(2015, 2, 1))
    assert True == customer.is_expiring
def test_is_expiring_none():
    customer = CustomerFactory()
    assert False == customer.is_expiring
def test_is_expiring_future():
    customer = CustomerFactory(expiry_date=date(3000, 2, 1))
    assert False == customer.is_expiring
def test_customer_refresh_default():
    customer = CustomerFactory()
    assert False == customer.refresh