Changeset 12701
- Timestamp:
- 9 Mar 2015, 05:07:04 (10 years ago)
- Location:
- main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/payments
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/payments/demo_provider.py
r12688 r12701 2 2 from waeup.ikoba.interfaces import MessageFactory as _ 3 3 from waeup.ikoba.payments.interfaces import IPaymentGatewayService 4 from waeup.ikoba.payments.payment import Payment 4 from waeup.ikoba.payments.payment import Payment, get_payment 5 5 6 6 … … 21 21 payment.gateway_service = 'demo_creditcard' # must be grok.name above 22 22 payment.payer_id = payer.payer_id 23 # XXX: we should not have to store a payment before adding items 24 site = grok.getSite() 25 site['payments'][payment.payment_id] = payment 23 26 for item in payment_item_list: 24 27 payment.add_payment_item(item) 25 28 return payment 29 30 def next_step(self, payment_id): 31 """Tell where to go next. 32 33 Returns (context, view_name). Both may be none. 34 """ 35 payment = get_payment(payment_id) 36 if payment is None: 37 return None, None 38 return payment, 'index' -
main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/payments/interfaces.py
r12671 r12701 102 102 """ 103 103 104 def next_step(payment_id): 105 """Returns a payment (as context) and a view name. 106 107 May result in (None, None). 108 """ 109 104 110 105 111 class IPaymentGatewayServicesLister(Interface): -
main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/payments/tests/test_demo_provider.py
r12671 r12701 1 1 import decimal 2 from zope.component import queryUtility 3 from zope.component.hooks import setSite 2 4 from zope.interface.verify import verifyClass, verifyObject 3 5 from waeup.ikoba.testing import ( … … 7 9 IPaymentGatewayService, IPayment, STATE_UNPAID, 8 10 ) 9 from waeup.ikoba.payments.payment import Payer, PaymentItem, Payee 11 from waeup.ikoba.app import Company 12 from waeup.ikoba.payments.payment import Payer, PaymentItem, Payee, Payment 10 13 from waeup.ikoba.payments.demo_provider import ( 11 14 DemoCreditcardPaymentService, … … 16 19 17 20 layer = FunctionalLayer 21 22 def setUp(self): 23 super(DemoCreditcarPaymentServiceTests, self).setUp() 24 self.app = Company() 25 self.getRootFolder()['app'] = self.app 26 setSite(self.app) 18 27 19 28 def test_iface(self): … … 56 65 def test_get_service_by_utility_name(self): 57 66 # we can get the demo credit card service by its utility name 58 from zope.component import queryUtility59 67 service = queryUtility( 60 68 IPaymentGatewayService, name="demo_creditcard") 61 69 assert service is not None 70 71 def test_next_step_invalid_id(self): 72 # we cannot go to non-existent payments 73 service = DemoCreditcardPaymentService() 74 result = service.next_step('not-existent-payment-id') 75 assert result == (None, None) 76 77 def test_next_step(self): 78 # we are redirected to 'index' in the beginning 79 service = DemoCreditcardPaymentService() 80 p1 = Payment() 81 self.app['payments']['1'] = p1 82 p_id = p1.payment_id 83 result = service.next_step(p_id) 84 assert result == (p1, 'index')
Note: See TracChangeset for help on using the changeset viewer.