Changeset 13873 for main


Ignore:
Timestamp:
4 Jun 2016, 04:43:01 (9 years ago)
Author:
Henrik Bettermann
Message:

Add checkConversion test.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/applicants
Files:
2 edited

Legend:

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

    r13872 r13873  
    2020import unicodecsv as csv # XXX: csv ops should move to dedicated module.
    2121import grok
     22from time import time
    2223from zope.schema import getFields
    2324from zope.interface import Interface
     
    341342    """The Applicant Online Payment Processor imports applicant payment tickets.
    342343    The tickets are located in the applicant container.
    343     The only additional locator is `p_id`, the object id.
    344344
    345345    The `checkConversion` method checks the format of the payment identifier.
     
    365365    def available_fields(self):
    366366        af = sorted(list(set(
    367             self.location_fields + getFields(self.iface).keys())) + ['p_id',])
     367            self.location_fields + getFields(self.iface).keys())))
    368368        af.remove('display_item')
    369369        return af
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_batching.py

    r13872 r13873  
    2525import unittest
    2626import grok
     27from time import time
    2728from hurry.workflow.interfaces import IWorkflowState
    2829from zope.component.hooks import setSite, clearSite
     
    498499            dict(applicant_id=self.applicant2.applicant_id, p_id='p456'), self.app)
    499500
     501    def test_checkConversion(self):
     502        errs, inv_errs, conv_dict = self.processor.checkConversion(
     503            dict(p_id='<IGNORE>'), mode='create')
     504        self.assertEqual(len(errs),0)
     505        errs, inv_errs, conv_dict = self.processor.checkConversion(
     506            dict(p_id='<IGNORE>'), mode='update')
     507        self.assertEqual(len(errs),1)
     508        self.assertEqual(errs[0], ('p_id', u'missing'))
     509        errs, inv_errs, conv_dict = self.processor.checkConversion(
     510            dict(p_id='p1266236341955'))
     511        self.assertEqual(len(errs),0)
     512        errs, inv_errs, conv_dict = self.processor.checkConversion(
     513            dict(p_id='nonsense'))
     514        self.assertEqual(len(errs),1)
     515        self.assertEqual(errs[0], ('p_id', u'invalid length'))
     516        timestamp = ("%d" % int(time()*10000))[1:]
     517        p_id = "p%s" % timestamp
     518        errs, inv_errs, conv_dict = self.processor.checkConversion(
     519            dict(p_id=p_id))
     520        self.assertEqual(len(errs),0)
     521        dup_payment = createObject(u'waeup.ApplicantOnlinePayment')
     522        dup_payment.p_id = 'p1266236341955'
     523        self.applicant2[dup_payment.p_id] = dup_payment
     524        errs, inv_errs, conv_dict = self.processor.checkConversion(
     525            dict(p_id='p1266236341955'), mode='create')
     526        self.assertEqual(len(errs),1)
     527        self.assertEqual(errs[0], ('p_id', u'p_id exists in dp2011_1234 '))
     528
    500529    def test_import(self):
    501530        num, num_warns, fin_file, fail_file = self.processor.doImport(
Note: See TracChangeset for help on using the changeset viewer.