Ignore:
Timestamp:
20 Mar 2015, 13:07:29 (10 years ago)
Author:
uli
Message:

Remove item_id from PaymentItem?.

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  
    254254
    255255    def __init__(
    256             self, item_id=u"0", title=u"", amount=decimal.Decimal("0.00")):
     256            self, title=u"", amount=decimal.Decimal("0.00")):
    257257        super(PaymentItem, self).__init__()
    258         self.item_id = item_id
    259258        self.title = title
    260259        self.amount = amount
    261260
    262261    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)
    265264        return result
    266265
     
    271270        ``(u'<ITEM_ID>', u'<TITLE>', u'<AMOUNT>')``.
    272271        """
    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)
    275273        string = string.replace("u'None'", "None")
    276274        return string
  • main/waeup.ikoba/trunk/src/waeup/ikoba/payments/tests/test_export.py

    r12779 r12800  
    109109        self.assertMatches(
    110110            '...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\')]",'
    112112            '64,My Contract...' % self.payment.payment_id,
    113113            result
     
    126126        self.assertMatches(
    127127            '...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\')]",'
    129129            '64,My Contract...' % self.payment.payment_id,
    130130            result
  • main/waeup.ikoba/trunk/src/waeup/ikoba/payments/tests/test_payment.py

    r12790 r12800  
    2121import re
    2222import unittest
     23from decimal import Decimal
    2324from zope.component import (
    2425    getUtilitiesFor, getSiteManager, queryUtility, getGlobalSiteManager,
     
    5253
    5354FAKE_PAYMENT_ITEMS = (
    54     PaymentItem(u'ITEM1', u'Item title 1', decimal.Decimal("1.00")),
    55     PaymentItem(u'ITEM2', 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")),
    5657    )
    5758
     
    375376        obj = PaymentItem()
    376377        self.assertEqual(
    377             obj.to_string(), u"(u'0', u'', u'0.00')")
     378            obj.to_string(), u"(u'', u'0.00')")
    378379
    379380    def test_to_string_none_values(self):
     
    382383        obj.item_id = None
    383384        self.assertEqual(
    384             obj.to_string(), u"(None, u'', u'0.00')")
     385            obj.to_string(), u"(u'', u'0.00')")
    385386
    386387    def test_to_string_enocded_values(self):
     
    389390        obj.title = u'ümläut'
    390391        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')")
    392393
    393394    def test_repr(self):
     
    396397        self.assertEqual(
    397398            repr(obj),
    398             "PaymentItem(item_id=u'0', title=u'', amount=Decimal('0.00'))")
     399            "PaymentItem(title=u'', amount=Decimal('0.00'))")
    399400
    400401    def test_repr_can_be_evaled(self):
    401402        # 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"))
    404404        representation = repr(obj)
    405405        self.assertEqual(
    406406            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'))"
    409408            )
    410         from decimal import Decimal
    411409        new_obj = eval(representation)
    412410        assert new_obj is not obj
    413         assert new_obj.item_id == obj.item_id == u"12"
    414411        assert new_obj.title == obj.title == u"My Title"
    415412        assert new_obj.amount == obj.amount == Decimal("1.99")
Note: See TracChangeset for help on using the changeset viewer.