Changeset 12800 for main/waeup.ikoba/trunk
- Timestamp:
- 20 Mar 2015, 13:07:29 (10 years ago)
- Location:
- main/waeup.ikoba/trunk/src/waeup/ikoba/payments
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/payments/payment.py
r12793 r12800 254 254 255 255 def __init__( 256 self, item_id=u"0",title=u"", amount=decimal.Decimal("0.00")):256 self, title=u"", amount=decimal.Decimal("0.00")): 257 257 super(PaymentItem, self).__init__() 258 self.item_id = item_id259 258 self.title = title 260 259 self.amount = amount 261 260 262 261 def __repr__(self): 263 result = "%s( item_id=%r,title=%r, amount=%r)" % (264 self.__class__.__name__, self. item_id, self.title, self.amount)262 result = "%s(title=%r, amount=%r)" % ( 263 self.__class__.__name__, self.title, self.amount) 265 264 return result 266 265 … … 271 270 ``(u'<ITEM_ID>', u'<TITLE>', u'<AMOUNT>')``. 272 271 """ 273 string = u"(u'%s', u'%s', u'%s')" % ( 274 self.item_id, self.title, self.amount) 272 string = u"(u'%s', u'%s')" % (self.title, self.amount) 275 273 string = string.replace("u'None'", "None") 276 274 return string -
main/waeup.ikoba/trunk/src/waeup/ikoba/payments/tests/test_export.py
r12779 r12800 109 109 self.assertMatches( 110 110 '...2015-03-16 16:07:33.273297#,EUR,demo_creditcard,CON1,' 111 ',K1000000,,%s,"[(u\' 0\', u\'Any product option\', u\'88.8\')]",'111 ',K1000000,,%s,"[(u\'Any product option\', u\'88.8\')]",' 112 112 '64,My Contract...' % self.payment.payment_id, 113 113 result … … 126 126 self.assertMatches( 127 127 '...2015-03-16 16:07:33.273297#,EUR,demo_creditcard,CON1,' 128 ',K1000000,,%s,"[(u\' 0\', u\'Any product option\', u\'88.8\')]",'128 ',K1000000,,%s,"[(u\'Any product option\', u\'88.8\')]",' 129 129 '64,My Contract...' % self.payment.payment_id, 130 130 result -
main/waeup.ikoba/trunk/src/waeup/ikoba/payments/tests/test_payment.py
r12790 r12800 21 21 import re 22 22 import unittest 23 from decimal import Decimal 23 24 from zope.component import ( 24 25 getUtilitiesFor, getSiteManager, queryUtility, getGlobalSiteManager, … … 52 53 53 54 FAKE_PAYMENT_ITEMS = ( 54 PaymentItem(u'I TEM1', u'Item title 1', decimal.Decimal("1.00")),55 PaymentItem(u'I TEM2', u'Item title 2', decimal.Decimal("2.2")),55 PaymentItem(u'Item title 1', decimal.Decimal("1.00")), 56 PaymentItem(u'Item title 2', decimal.Decimal("2.2")), 56 57 ) 57 58 … … 375 376 obj = PaymentItem() 376 377 self.assertEqual( 377 obj.to_string(), u"(u' 0', u'', u'0.00')")378 obj.to_string(), u"(u'', u'0.00')") 378 379 379 380 def test_to_string_none_values(self): … … 382 383 obj.item_id = None 383 384 self.assertEqual( 384 obj.to_string(), u"( None,u'', u'0.00')")385 obj.to_string(), u"(u'', u'0.00')") 385 386 386 387 def test_to_string_enocded_values(self): … … 389 390 obj.title = u'ümläut' 390 391 self.assertEqual( 391 obj.to_string(), u"(u' 0', u'ümläut', u'0.00')")392 obj.to_string(), u"(u'ümläut', u'0.00')") 392 393 393 394 def test_repr(self): … … 396 397 self.assertEqual( 397 398 repr(obj), 398 "PaymentItem( item_id=u'0',title=u'', amount=Decimal('0.00'))")399 "PaymentItem(title=u'', amount=Decimal('0.00'))") 399 400 400 401 def test_repr_can_be_evaled(self): 401 402 # we can eval() representations 402 obj = PaymentItem( 403 item_id=u'12', title=u'My Title', amount=decimal.Decimal("1.99")) 403 obj = PaymentItem(title=u'My Title', amount=decimal.Decimal("1.99")) 404 404 representation = repr(obj) 405 405 self.assertEqual( 406 406 representation, 407 ("PaymentItem(item_id=u'12', title=u'My Title', " 408 "amount=Decimal('1.99'))") 407 "PaymentItem(title=u'My Title', amount=Decimal('1.99'))" 409 408 ) 410 from decimal import Decimal411 409 new_obj = eval(representation) 412 410 assert new_obj is not obj 413 assert new_obj.item_id == obj.item_id == u"12"414 411 assert new_obj.title == obj.title == u"My Title" 415 412 assert new_obj.amount == obj.amount == Decimal("1.99")
Note: See TracChangeset for help on using the changeset viewer.