Ignore:
Timestamp:
12 Jun 2012, 21:01:17 (12 years ago)
Author:
Henrik Bettermann
Message:

Catalogue all kinds of payments not only student payments.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_catalog.py

    r7811 r8700  
    2121import shutil
    2222import tempfile
     23import grok
     24from zope.component import getUtility, createObject
    2325from hurry.query import Eq
    2426from hurry.query.interfaces import IQuery
     
    8688        self.assertTrue(isinstance(result_applicant, Applicant))
    8789        self.assertEqual(result_applicant.applicant_id, self.applicant.applicant_id)
     90
     91    def test_get_payment(self):
     92        self.create_applicant()
     93        q = getUtility(IQuery)
     94        subquery = Eq(('applicants_catalog', 'applicant_id'),
     95            self.applicant.applicant_id)
     96        results = list(q.searchResults(subquery))
     97        self.assertEqual(len(results), 1)
     98        result_applicant = results[0]
     99        payment = createObject('waeup.ApplicantOnlinePayment')
     100        payment.p_id = 'p1234567890'
     101        payment.p_item = u'Payment Item'
     102        payment.p_session = 2011
     103        payment.p_category = 'application'
     104        result_applicant[payment.p_id] = payment
     105        # We can find a payment ticket by the payment session ...
     106        cat = getUtility(ICatalog, name='payments_catalog')
     107        results = cat.searchResults(p_session=(2011, 2011))
     108        results = [x for x in results] # Turn results generator into list
     109        assert len(results) == 1
     110        assert results[0] is result_applicant['p1234567890']
     111        # ... and by the payment id
     112        results = cat.searchResults(p_id=('p1234567890', 'p1234567890'))
     113        assert len(results) == 1
     114        # If we remove the applicant also the payment disappears
     115        del self.app['applicants']['mystuff'][result_applicant.application_number]
     116        results = cat.searchResults(p_id=('p1234567890', 'p1234567890'))
     117        assert len(results) == 0
Note: See TracChangeset for help on using the changeset viewer.