Ignore:
Timestamp:
18 Mar 2015, 14:08:18 (10 years ago)
Author:
uli
Message:

Provide proper repr() for PaymentItems?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/payments/tests/test_payment.py

    r12789 r12790  
    390390        self.assertEqual(
    391391            obj.to_string(), u"(u'0', u'ümläut', u'0.00')")
     392
     393    def test_repr(self):
     394        # we can get a proper representation of PaymentItem
     395        obj = PaymentItem()
     396        self.assertEqual(
     397            repr(obj),
     398            "PaymentItem(item_id=u'0', title=u'', amount=Decimal('0.00'))")
     399
     400    def test_repr_can_be_evaled(self):
     401        # we can eval() representations
     402        obj = PaymentItem(
     403            item_id=u'12', title=u'My Title', amount=decimal.Decimal("1.99"))
     404        representation = repr(obj)
     405        self.assertEqual(
     406            representation,
     407            ("PaymentItem(item_id=u'12', title=u'My Title', "
     408             "amount=Decimal('1.99'))")
     409            )
     410        from decimal import Decimal
     411        new_obj = eval(representation)
     412        assert new_obj is not obj
     413        assert new_obj.item_id == obj.item_id == u"12"
     414        assert new_obj.title == obj.title == u"My Title"
     415        assert new_obj.amount == obj.amount == Decimal("1.99")
Note: See TracChangeset for help on using the changeset viewer.