def test_mark_old_credit_cards(self, session, credit_cards):
        """ Credit cards that are about to expire should get marked. """
        may_29_2015 = datetime.date(2015, 05, 29)
        june_29_2015 = datetime.date(2015, 06, 29)

        CreditCard.mark_old_credit_cards(may_29_2015)

        card = CreditCard.query.filter(CreditCard.exp_date == june_29_2015)
        assert True == card.first().is_expiring
    def test_avoid_marking_up_to_date_credit_cards(self, session,
                                                   credit_cards):
        """ Credit cards that are not expiring should not be marked. """
        may_29_2015 = datetime.date(2015, 05, 29)
        may_28_2016 = datetime.date(2016, 05, 28)

        CreditCard.mark_old_credit_cards(may_29_2015)

        card = CreditCard.query.filter(CreditCard.exp_date == may_28_2016)
        assert False == card.first().is_expiring
Пример #3
0
def mark_old_credit_cards():
    """
    Mark credit cards that are going to expire soon or have expired.

    :return: Result of updating the records
    """
    return CreditCard.mark_old_credit_cards()