source: main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/payments/tests/test_payment.py @ 12133

Last change on this file since 12133 was 12133, checked in by uli, 10 years ago

Add first tests for local Payment.

File size: 1.6 KB
Line 
1## $Id$
2##
3## Copyright (C) 2014 Uli Fouquet & Henrik Bettermann
4## This program is free software; you can redistribute it and/or modify
5## it under the terms of the GNU General Public License as published by
6## the Free Software Foundation; either version 2 of the License, or
7## (at your option) any later version.
8##
9## This program is distributed in the hope that it will be useful,
10## but WITHOUT ANY WARRANTY; without even the implied warranty of
11## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12## GNU General Public License for more details.
13##
14## You should have received a copy of the GNU General Public License
15## along with this program; if not, write to the Free Software
16## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17##
18import re
19import unittest
20from zope.interface.verify import verifyClass, verifyObject
21from waeup.ikoba.payments.interfaces import IPayment
22from waeup.ikoba.payments.payment import Payment
23
24
25class PaymentTests(unittest.TestCase):
26
27    def test_iface(self):
28        # Payments fullfill any interface contracts
29        obj = Payment()
30        verifyClass(IPayment, Payment)
31        verifyObject(IPayment, obj)
32
33    def test_payment_id_unique(self):
34        # we get unique payment ids
35        p1, p2 = Payment(), Payment()
36        id1, id2 = p1.payment_id, p2.payment_id
37        assert id1 != id2
38
39    def test_payment_id_format(self):
40        # payment ids have a special format: "PAY_<32 hex digits>"
41        id1 = Payment().payment_id
42        assert isinstance(id1, basestring)
43        assert re.match('PAY_[0-9a-f]{32}', id1)
Note: See TracBrowser for help on using the repository browser.