Changeset 12727 for main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/customers/tests/test_contract.py
- Timestamp:
- 11 Mar 2015, 10:07:50 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/customers/tests/test_contract.py
r12718 r12727 29 29 from waeup.ikoba.customers.contracts import ( 30 30 ContractsContainer, SampleContract, payment_items_from_contract, 31 ContractPayer, ContractFinder 31 ContractPayer, ContractFinder, PayableContract, 32 32 ) 33 33 from waeup.ikoba.app import Company 34 34 from waeup.ikoba.customers.customer import Customer 35 35 from waeup.ikoba.payments.interfaces import ( 36 IPaymentItem, IPayer, IPayableFinder, 36 IPaymentItem, IPayer, IPayableFinder, IPayable, 37 37 ) 38 38 from waeup.ikoba.products.productoptions import ProductOption … … 187 187 result = finder.get_payable_by_id('CON1234') 188 188 self.assertTrue(result is None) 189 190 191 class TestContractAsPayable(FunctionalTestCase): 192 193 layer = FunctionalLayer 194 195 def test_adaptable(self): 196 # we can turn contracts into payables. 197 contract = SampleContract() 198 payable = IPayable(contract) 199 self.assertTrue(payable is not None) 200 self.assertTrue(isinstance(payable, PayableContract)) 201 202 def test_payable_iface(self): 203 # PayableContracts really provide IPayable 204 contract = SampleContract() 205 option1 = ProductOption(u"Fee 1", decimal.Decimal("31.10"), "USD") 206 option2 = ProductOption(u"Fee 2", decimal.Decimal("12.12"), "USD") 207 contract.product_options = [option1, option2] 208 payable = PayableContract(contract) 209 verifyObject(IPayable, payable) 210 verifyClass(IPayable, PayableContract) 211 212 def test_payable_simple_attributes(self): 213 # the simple attribs are set correctly, according to context contract 214 contract = SampleContract() 215 contract.title = u'the title' 216 option1 = ProductOption(u"Fee 1", decimal.Decimal("31.10"), "EUR") 217 option2 = ProductOption(u"Fee 2", decimal.Decimal("12.12"), "EUR") 218 contract.product_options = [option1, option2] 219 payable = PayableContract(contract) 220 self.assertTrue(contract.contract_id, payable.payable_id) 221 self.assertEqual(payable.title, contract.title) 222 self.assertEqual(payable.currency, 'EUR') 223 224 def test_payable_items(self): 225 # we can get payment items from payable 226 contract = SampleContract() 227 option1 = ProductOption(u"Fee 1", decimal.Decimal("31.10"), "EUR") 228 option2 = ProductOption(u"Fee 2", decimal.Decimal("12.12"), "EUR") 229 contract.product_options = [option1, option2] 230 payable = PayableContract(contract) 231 items = payable.payment_items 232 self.assertTrue(isinstance(items, tuple)) 233 self.assertEqual(len(items), 2) 234 verifyObject(IPaymentItem, items[0]) 235 verifyObject(IPaymentItem, items[1]) 236 self.assertEqual(items[0].item_id, '0') 237 self.assertEqual(items[0].title, u'Fee 1') 238 self.assertEqual(items[0].amount, decimal.Decimal("31.10")) 239 240 def test_payable_no_items(self): 241 # payables work also with no options set on contract 242 contract = SampleContract() 243 payable = PayableContract(contract) 244 items = payable.payment_items 245 self.assertTrue(isinstance(items, tuple)) 246 self.assertEqual(len(items), 0) 247 self.assertEqual(payable.currency, None) 248 249 def test_different_currencies_forbiddedn(self): 250 # we do not accept different currencies in payment items 251 contract = SampleContract() 252 option1 = ProductOption(u"Fee 1", decimal.Decimal("31.10"), "EUR") 253 option2 = ProductOption(u"Fee 2", decimal.Decimal("12.12"), "USD") 254 contract.product_options = [option1, option2] 255 self.assertRaises(ValueError, PayableContract, contract)
Note: See TracChangeset for help on using the changeset viewer.