Ignore:
Timestamp:
24 Mar 2015, 11:51:08 (10 years ago)
Author:
uli
Message:

Find payment ids also if only the beginning is given.

File:
1 edited

Legend:

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

    r12822 r12824  
     1import decimal
    12from zope.catalog.interfaces import ICatalog
    23from zope.component import queryUtility
    34from zope.component.hooks import setSite
    45from waeup.ikoba.app import Company
    5 from waeup.ikoba.payments.payment import Payment
     6from waeup.ikoba.payments.payment import Payment, PaymentItem
    67from waeup.ikoba.payments.testing import FakePayer, FakePayable
    78from waeup.ikoba.testing import FunctionalLayer, FunctionalTestCase
     
    4546        result = [x for x in result]
    4647        self.assertEqual(len(result), 1)
     48
     49    def test_search_payer_id_starts_with_query(self):
     50        # we can find payer_ids starting with query string.
     51        app = self.create_app()
     52        payer1, payer2, payer3 = FakePayer(), FakePayer(), FakePayer()
     53        payer1.payer_id = u'PAYER_11'
     54        payer2.payer_id = u'PAYER_12'
     55        payer3.payer_id = u'PAYER_20'
     56        payment1 = Payment(payer=payer1, payable=FakePayable())
     57        payment2 = Payment(payer=payer2, payable=FakePayable())
     58        payment3 = Payment(payer=payer3, payable=FakePayable())
     59        app['p1'], app['p2'], app['p3'] = payment1, payment2, payment3
     60        result1 = search(query='PAYER_1', searchtype='payer_id')
     61        result1 = [x for x in result1]
     62        self.assertEqual(len(result1), 2)
     63        result2 = search(query='PAYER_2', searchtype='payer_id')
     64        result2 = [x for x in result2]
     65        self.assertEqual(len(result2), 1)
     66        result3 = search(query='PAYER_3', searchtype='payer_id')
     67        result3 = [x for x in result3]
     68        self.assertEqual(len(result3), 0)
     69        result4 = search(query='PAYER_11', searchtype='payer_id')
     70        result4 = [x for x in result4]
     71        self.assertEqual(len(result4), 1)
     72
     73    def test_search_amount(self):
     74        # we can find given amounts starting with query string.
     75        app = self.create_app()
     76        payable1, payable2 = FakePayable(), FakePayable()
     77        payable1.payment_items = (
     78            PaymentItem(u'Item 1', decimal.Decimal("1.0")), )
     79        payable2.payment_items = (
     80            PaymentItem(u'Item 2', decimal.Decimal("2.0")), )
     81        payment1 = Payment(payer=FakePayer(), payable=payable1)
     82        payment2 = Payment(payer=FakePayer(), payable=payable2)
     83        app['p1'], app['p2'] = payment1, payment2
     84        result1 = search(query=decimal.Decimal("1.00"), searchtype='amount')
     85        result1 = [x for x in result1]
     86        self.assertEqual(len(result1), 1)
     87        result2 = search(query=decimal.Decimal("2.00"), searchtype='amount')
     88        result2 = [x for x in result2]
     89        self.assertEqual(len(result2), 1)
     90        result3 = search(query=decimal.Decimal("3.00"), searchtype='amount')
     91        result3 = [x for x in result3]
     92        self.assertEqual(len(result3), 0)
Note: See TracChangeset for help on using the changeset viewer.