Changeset 12728 for main/waeup.ikoba/branches/uli-payments
- Timestamp:
- 11 Mar 2015, 10:16:58 (10 years ago)
- Location:
- main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/customers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/customers/contracts.py
r12727 r12728 61 61 62 62 63 def payment_items_from_contract(contract):64 """Turn contract product options into payment items.65 """66 result = []67 for num, option in enumerate(contract.product_options):68 item = PaymentItem()69 item.item_id = u'%s' % num70 item.title = option.title71 item.amount = option.fee72 result.append(item)73 return result74 75 76 63 class ContractPayer(grok.Adapter): 77 64 """Adapter to turn contracts into IPayers. -
main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/customers/tests/test_contract.py
r12727 r12728 28 28 IContractsContainer, IContract) 29 29 from waeup.ikoba.customers.contracts import ( 30 ContractsContainer, SampleContract, payment_items_from_contract,31 ContractPayer, ContractFinder,PayableContract,30 ContractsContainer, SampleContract, ContractPayer, ContractFinder, 31 PayableContract, 32 32 ) 33 33 from waeup.ikoba.app import Company … … 105 105 layer = FunctionalLayer 106 106 107 def test_payment_items_from_contract(self):108 # we can turn contracts into lists of payment items109 contract = SampleContract()110 option1 = ProductOption(u"Fee 1", decimal.Decimal("31.10"), "USD")111 option2 = ProductOption(u"Fee 2", decimal.Decimal("12.12"), "USD")112 contract.product_options = [option1, option2]113 payment_items = payment_items_from_contract(contract)114 assert len(payment_items) == 2115 item1, item2 = payment_items116 assert IPaymentItem.providedBy(item1)117 assert IPaymentItem.providedBy(item2)118 assert item1.item_id == "0"119 assert item2.item_id == "1"120 assert item1.title == u'Fee 1'121 assert item2.title == u'Fee 2'122 assert item1.amount == decimal.Decimal("31.10")123 assert item2.amount == decimal.Decimal("12.12")124 125 def test_payment_item_from_contract_no_options(self):126 # we cope with empty contracts127 contract = SampleContract()128 payment_items = payment_items_from_contract(contract)129 assert payment_items == []130 131 107 def test_payer_adapter(self): 132 108 # we can adapt IContract to IPayer (i.e. create a payer)
Note: See TracChangeset for help on using the changeset viewer.