- Timestamp:
- 10 Mar 2015, 16:01:59 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/payments/tests/test_payment.py
r12700 r12719 20 20 import re 21 21 import unittest 22 from zope.component import getUtilitiesFor, getSiteManager, queryUtility 22 from zope.component import ( 23 getUtilitiesFor, getSiteManager, queryUtility, getGlobalSiteManager, 24 ) 23 25 from zope.component.hooks import setSite 24 26 from zope.interface import implements … … 27 29 IPayment, STATE_UNPAID, STATE_PAID, STATE_FAILED, 28 30 IPaymentGatewayService, IPaymentItem, IPaymentGatewayServicesLister, 31 IPayableFinder, 29 32 ) 30 33 from waeup.ikoba.app import Company 31 34 from waeup.ikoba.payments.payment import ( 32 35 Payment, get_payment_providers, PaymentItem, format_payment_item_values, 33 get_payment, 36 get_payment, find_payable_from_payable_id, 34 37 ) 35 38 from waeup.ikoba.testing import (FunctionalLayer, FunctionalTestCase) … … 118 121 p1.add_payment_item(item1) 119 122 p_id = p1.payment_id 120 result = get_payment(p_id)123 result = get_payment(p_id) 121 124 self.assertTrue(result is p1) 122 125 self.assertTrue(get_payment('not-valid') is None) 126 127 def test_find_payable_from_payable_id(self): 128 # we can find payables. 129 obj1 = object() 130 obj2 = object() 131 132 class FakeFinder(object): 133 valid = {'id1': obj1, 'id3': obj2} 134 135 def get_payable_by_id(self, the_id): 136 return self.valid.get(the_id) 137 138 finder1 = FakeFinder() 139 finder1.valid = {'id1': obj1} 140 finder2 = FakeFinder() 141 finder2.valid = {'id2': obj2} 142 gsm = getGlobalSiteManager() 143 try: 144 gsm.registerUtility(finder1, provided=IPayableFinder, name='f1') 145 gsm.registerUtility(finder2, provided=IPayableFinder, name='f2') 146 result1 = find_payable_from_payable_id('id1') 147 result2 = find_payable_from_payable_id('id2') 148 result3 = find_payable_from_payable_id('id3') 149 finally: 150 gsm.unregisterUtility(finder1, IPayableFinder) 151 gsm.unregisterUtility(finder2, IPayableFinder) 152 self.assertTrue(result1 is obj1) 153 self.assertTrue(result2 is obj2) 154 self.assertTrue(result3 is None) 123 155 124 156
Note: See TracChangeset for help on using the changeset viewer.