Changeset 12153


Ignore:
Timestamp:
5 Dec 2014, 17:14:19 (10 years ago)
Author:
uli
Message:

More tests for payments.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/payments/tests/test_payment.py

    r12133 r12153  
    1616## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1717##
     18import datetime
    1819import re
    1920import unittest
    2021from zope.interface.verify import verifyClass, verifyObject
    21 from waeup.ikoba.payments.interfaces import IPayment
     22from waeup.ikoba.payments.interfaces import (
     23    IPayment, STATE_UNPAID, STATE_PAID, STATE_FAILED,
     24    )
    2225from waeup.ikoba.payments.payment import Payment
    2326
     
    4245        assert isinstance(id1, basestring)
    4346        assert re.match('PAY_[0-9a-f]{32}', id1)
     47
     48    def test_initial_state_is_unpaid(self):
     49        # the initial state of payments is <unpaid>
     50        p1 = Payment()
     51        p1.state == STATE_PAID
     52
     53    def test_approve(self):
     54        # we can approve payments
     55        p1 = Payment()
     56        p1.approve()
     57        assert p1.state == STATE_PAID
     58        assert p1.payment_date is not None
     59        assert isinstance(p1.payment_date, datetime.datetime)
     60
     61    def test_approve_datetime_given(self):
     62        # we can give a datetime
     63        p1 = Payment()
     64        some_datetime = datetime.datetime(2014, 1, 1, 0, 0, 0)
     65        p1.approve(payment_date=some_datetime)
     66        assert p1.payment_date == some_datetime
     67
     68    def test_approve_datetime_automatic(self):
     69        # if we do not give a datetime, current one will be used
     70        current = datetime.datetime.utcnow()
     71        p1 = Payment()
     72        p1.approve()
     73        assert p1.payment_date >= current
     74
     75    def test_mark_failed(self):
     76        # we can mark payments as failed
     77        p1 = Payment()
     78        p1.mark_failed()
     79        assert p1.state == STATE_FAILED
Note: See TracChangeset for help on using the changeset viewer.