Changeset 12648 for main/waeup.ikoba/branches
- Timestamp:
- 2 Mar 2015, 01:01:10 (10 years ago)
- Location:
- main/waeup.ikoba/branches/uli-fake-gw-provider/src/waeup/ikoba/payments
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/branches/uli-fake-gw-provider/src/waeup/ikoba/payments/payment.py
r12646 r12648 66 66 Equals the sum of items contained. 67 67 """ 68 return sum([item.amount for item in self.values()]) 68 return sum( 69 [item.amount for item in self.values()], 70 decimal.Decimal("0.00") # default value 71 ) 69 72 70 73 def __init__(self): -
main/waeup.ikoba/branches/uli-fake-gw-provider/src/waeup/ikoba/payments/tests/test_payment.py
r12644 r12648 17 17 ## 18 18 import datetime 19 import decimal 19 20 import re 20 21 import unittest … … 129 130 assert len(p1) == 2 # do not make assumptions about result content 130 131 132 def test_amount(self): 133 # the amount of a payment is the sum of amounts of its items 134 p1 = Payment() 135 item1 = PaymentItem() 136 item2 = PaymentItem() 137 p1.add_payment_item(item1) 138 p1.add_payment_item(item2) 139 item1.amount = decimal.Decimal("12.25") 140 item2.amount = decimal.Decimal("0.5") 141 assert p1.amount == decimal.Decimal("12.75") 142 143 def test_amount_negative(self): 144 # we can sum up negative numbers 145 p1 = Payment() 146 item1 = PaymentItem() 147 item2 = PaymentItem() 148 p1.add_payment_item(item1) 149 p1.add_payment_item(item2) 150 item1.amount = decimal.Decimal("2.21") 151 item2.amount = decimal.Decimal("-3.23") 152 assert p1.amount == decimal.Decimal("-1.02") 153 154 def test_amount_empty(self): 155 # the amount of zero items is 0.00. 156 p1 = Payment() 157 assert p1.amount == decimal.Decimal("0.00") 158 assert isinstance(p1.amount, decimal.Decimal) 159 131 160 132 161 class PaymentItemTests(unittest.TestCase):
Note: See TracChangeset for help on using the changeset viewer.